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:

routerA

Public IP: 87.65.43.21 Private network: 192.168.4.0/24 IP on that private network: 192.168.4.4

routerB

Public IP: 123.45.67.8 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 123.45.67.8 local 87.65.43.21 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 87.65.43.21 local 123.45.67.8 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.

Comments