If you have ssh then you can setup a "bridge" to any external network or server in minutes.
This doesn't replace standard VPN solutions, but it has the advantage of being really simple and fast and will serve a lot of use-cases.
- Each client must have a separate TUN device on the target server (TODO: Check if this is really true)
For demonstration purposes the following parameters are used:
- VPN Virtual Network Subnet:
10.5.5.0/24 - VPN Server Virtual Network Address:
10.5.5.1 - VPN Server Virtual Network TUN Device:
tun5 - VPN Server Host:
vpn-server.example.com - VPN Server SSHD Port:
22 - VPN Server SSH Username:
root - VPN Client Virtual Network TUN Device:
tun5
You should already have an SSH server running with access set up.
The configuration is usually in /etc/ssh/sshd_config. After changed reload
the service via systemctl reload sshd or service sshd reload.
PermitTunnel yes
ClientAliveInterval 60
ClientAliveCountMax 10
This is not needed usually, most distros have this disabled by default.
sysctl -w net.ipv4.conf.all.rp_filter=0
sysctl -w net.ipv4.conf.tun0.rp_filter=0ssh \
-o PermitLocalCommand=yes \
-o LocalCommand="ifconfig tun0 10.13.40.10 10.13.40.1 netmask 255.255.255.0 up" \
-w 0:0 \
-N \
-v \
user@target