I am trying to configure a tun2socks server that forwards all traffic to an external proxy found online. I also want to retain the ability to ssh into the server so I had to take this into consideration. So far the steps I have gathered are the following:
- Download the latest release of tun2socks from github
- ip tuntap add mode tun dev tun0
- ip addr add 198.18.0.1/15 dev tun0
- ip link set dev tun0 up
- ip route del default
- ip route add default via 198.18.0.1 dev tun0 metric 1
- ip route add default via 172.17.0.1 dev eth0 metric 10
- iptables -t nat -A PREROUTING -i eth0 -d 172.17.0.1 -j DNAT --to 192.18.0.1
- iptables -A FORWARD -i eth0 -d 172.17.0.1 --dport 22 -j REJECT
- iptables -A FORWARD -i eth0 -d 172.17.0.1 -j ACCEPT
- iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
- sudo ./tun2socks-linux-amd64-v3 -device tun://tun0 -proxy socks5://external-proxy:port
What am I doing wrong? I know there are a lot of commands here but it seems like there should be some instructions somewhere for this.