This article was first written in August 2004 for the BeezNest technical website (http://glasnost.beeznest.org/articles/166).
Setting an IP in IP or GRE tunnel using iproute between two Linux routers is relatively easy.
Given the following two routers, each one gateway for its network:
Public IP: 188.8.131.52
Private network: 192.168.4.0/24
IP on that private network: 192.168.4.4
Public IP: 184.108.40.206
Private network: 192.168.10.0/24
IP on that private network: 192.168.10.4
To setup routerA, will issue the following commands on the command line, after having loaded the ipip or ip_gre module
# ip tunnel add routerb mode gre remote 220.127.116.11 local 18.104.22.168 ttl 255 # ip link set routerb up # ip addr add 192.168.10.4 dev routerb # ip route add 192.168.4.0/24 dev routerb
and of course the following on routerB
# ip tunnel add routera mode gre remote 22.214.171.124 local 126.96.36.199 ttl 255 # ip link set routera up # ip addr add 192.168.4.4 dev routera # ip route add 192.168.0.0/24 dev routera
See also http://lackof.org/taggart/tunnel/ or http://www.linuxguruz.com/iptables/howto/2.4routing-5.html keeping in mind that IP in IP and GRE tunnels are similarily configured using iproute.