WiFi connected using wlan0 on address range 172.20.10.0/28
sudo su
apk install autossh
modprobe tun
sysctl -w net.ipv4.ip_forward=1
# ip tuntap add dev tun0 mode tun user root
# The ssh conn will create the Tun interfaces for both server and client
autossh ${SERVER_PUBLIC_IP} \
-M 0 \
-o "ServerAliveInterval 5" \
-o "ServerAliveCountMax 3" \
-o TCPKeepAlive=yes \
-NTCfw 0:0
ip addr add 10.0.0.1/32 peer 10.0.0.2 dev tun0
ip link set tun0 up
ip route add 192.168.1.0/24 via 10.0.0.2
iptables -t nat -A POSTROUTING -s 10.0.0.2 -o wlan0 -j MASQUERADE
Eth connected using eth0 on address range 192.168.1.0/24 + NAT on the ISP Box forwarding ${SERVER_PUBLIC_IP}:22 to ${SERVER_PRIVATE_IP}:22
sudo su
modprobe tun
sysctl -w net.ipv4.ip_forward=1
# ip tuntap add dev tun0 mode tun user root
# The ssh client conn will create the Tun interfaces for both server and client
ip addr add 10.0.0.2/32 peer 10.0.0.1 dev tun0
ip link set tun0 up
ip route add 172.20.10.0/28 via 10.0.0.1
iptables -t nat -A POSTROUTING -s 10.0.0.1 -o eth0 -j MASQUERADE
sshd must be configured with “PermitTunnel yes” (/etc/ssh/sshd_config)