Sunday, October 23, 2016

create udp tunnel using socat

*** setup information

client ip:
server ip:
target network:

client tunnel ip:
server tunnel ip:

*** on server
1- the the following command, it will listen on port 22222
$ socat -d -d TCP-LISTEN:22222,reuseaddr TUN:,up

2- enable ip_forward and the interface out to network
$ sudo sysctl -w net.ipv4.ip_forward=1
$ sudo iptables -t nat -A POSTROUTING -o ens39 -j MASQUERADE

*** on client
1- establish the udp tunnel to server
$ socat TCP: TUN:,up

2- route the target network via the new created tun device
$ sudo ip route add dev tun0

- snapshot of ip address of tun0 and successfully ping the target network

No comments:

Post a Comment