Friday, December 5, 2008

IP-to-IP tunneling

This works under Linux machine
SERVER A:

OS: Linux
Network Interface: eth0
IP: 172.16.0.1

SERVER B:

OS: Linux
Network Interface: eth0
IP: 172.16.0.2

Now we create the tunnel with following parameters.
SERVER A: 10.0.0.1 / 255.255.255.252
SERVER B: 10.0.0.2 / 255.255.255.252

In Server A:

ip tunnel add tun0 mode ipip remote 172.16.0.1 local 172.16.0.2 dev eth0
ifconfig tun0 10.0.0.1 netmask 255.255.255.252 pointopoint 10.0.0.2
ifconfig tun0 mtu 1500 up

In Server B:
ip tunnel add tun0 mode ipip remote 172.16.0.2 local 172.16.0.1 dev eth0
ifconfig tun0 10.0.0.2 netmask 255.255.255.252 pointopoint 10.0.0.1
ifconfig tun0 mtu 1500 up

Now ping 10.0.0.2 from server A:
64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=0.139 ms
64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=0.139 ms

Finish..

All the best.