Last active
December 22, 2023 20:30
-
-
Save aleskxyz/5af71f11ed99f2ea79df880c1c8b882e to your computer and use it in GitHub Desktop.
Tunnel over SSH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You can setup a tunnel over SSH with -w option as below. | |
Try it at home, not server! | |
Server side | |
=========== | |
ip tuntap add mode tun dev tun0 | |
ip addr add 192.168.16.1/30 dev tun0 | |
ip link set tun0 up | |
iptables -I FORWARD -o tun0 -i <public-interface> -j ACCEPT | |
iptables -I FORWARD -i tun0 -o <public-interface> -j ACCEPT | |
iptables -t nat -I POSTROUTING -o <public-interface> -j MASQUERADE | |
Client Side | |
=========== | |
ip tuntap add mode tun dev tun0 | |
ip addr add 192.168.16.2/30 dev tun0 | |
ip link set tun0 up | |
ssh -NTf -w 0:0 <username>@<server-ip> | |
ip route add <server-ip>/32 via <default-gw> | |
ip route add default via 192.168.16.1 metric 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment