IP in IP or GRE tunnel using iproute
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: 18.104.22.168
Private network: 192.168.4.0/24
IP on that private network: 192.168.4.4
Public IP: 22.214.171.124
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 126.96.36.199 local 188.8.131.52 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 184.108.40.206 local 220.127.116.11 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.