Difference between revisions of "Building a VPN tunnel from scratch"
Jump to navigation
Jump to search
| Line 25: | Line 25: | ||
= On-demand tunnel = | = On-demand tunnel = | ||
In the following 2 sections: | |||
* '''10.9.8.1''' & '''10.9.8.2''' are arbitrary private IPs | |||
* '''SERVER_IP''' is the NORMAL IP address or name of the machine acting as the server | |||
These commands can be run in the background to create the tunnel when needed. | |||
== | == On-demand server == | ||
* <code>sudo openvpn --dev tun1 --ifconfig '''10.9.8.1''' '''10.9.8.2'''</code> | |||
in a second terminal: | |||
* <code>ip a</code> | |||
& you should see a <code>tun1</code> entry like: | |||
9: tun1: <pointopoint,multicast,noarp,up,lower_up> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 500 | |||
link/none | |||
inet 10.9.8.1 peer 10.9.8.2/32 scope global tun1 | |||
valid_lft forever preferred_lft forever | |||
inet6 fe80::dc71:3707:693c:5017/64 scope link stable-privacy | |||
valid_lft forever preferred_lft forever | |||
== On-demand client == | |||
* <code>sudo openvpn --remote '''SERVER_IP''' --dev tun1 --ifconfig '''10.9.8.2''' '''10.9.8.1'''</code> | |||
in a second terminal: | |||
* <code>ip a</code> | |||
& you should see a <code>tun1</code> entry like: | |||
3: tun1: <pointopoint,multicast,noarp,up,lower_up> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 500 | |||
link/none | |||
inet 10.9.8.2 peer 10.9.8.1/32 scope global tun1 | |||
valid_lft forever preferred_lft forever | |||
inet6 fe80::4c39:d598:21b8:2b41/64 scope link stable-privacy | |||
valid_lft forever preferred_lft forever</pointopoint,multicast,noarp,up,lower_up> | |||
= Persistant (on-boot) tunnel = | = Persistant (on-boot) tunnel = | ||
Revision as of 16:47, 16 September 2025
| 13 (trixie) |
|
| As always... | |
|---|---|
|
Start with: |
|
Install openvpn
sudo apt install openvpn
On-demand tunnel
In the following 2 sections:
- 10.9.8.1 & 10.9.8.2 are arbitrary private IPs
- SERVER_IP is the NORMAL IP address or name of the machine acting as the server
These commands can be run in the background to create the tunnel when needed.
On-demand server
sudo openvpn --dev tun1 --ifconfig 10.9.8.1 10.9.8.2
in a second terminal:
ip a
& you should see a tun1 entry like:
9: tun1: <pointopoint,multicast,noarp,up,lower_up> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 500
link/none
inet 10.9.8.1 peer 10.9.8.2/32 scope global tun1
valid_lft forever preferred_lft forever
inet6 fe80::dc71:3707:693c:5017/64 scope link stable-privacy
valid_lft forever preferred_lft forever
On-demand client
sudo openvpn --remote SERVER_IP --dev tun1 --ifconfig 10.9.8.2 10.9.8.1
in a second terminal:
ip a
& you should see a tun1 entry like:
3: tun1: <pointopoint,multicast,noarp,up,lower_up> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 500
link/none
inet 10.9.8.2 peer 10.9.8.1/32 scope global tun1
valid_lft forever preferred_lft forever
inet6 fe80::4c39:d598:21b8:2b41/64 scope link stable-privacy
valid_lft forever preferred_lft forever</pointopoint,multicast,noarp,up,lower_up>