Tunneling: GRE Encapsulation
IP tunnels with GRE for supporting multicast and Cisco devices.
GRE
stands for Generic
Routing Encapsulation. Like IPIP tunneling
[Hack #54], GRE is an
unencrypted encapsulation protocol. The main advantages of using GRE
instead of IPIP are that it supports
multicast packets, and that it also
interoperates with Cisco routers.
Just as with the IPIP tunneling hack, I assume that you have two private networks (10.42.1.0/24 and 10.42.2.0/24), and that these networks both have direct Internet connectivity via a Linux router at each network. The “real” IP address of the first network router is 240.101.83.2, and the “real” IP of the second router is 251.4.92.217.
Again, as with IPIP tunneling, you also need a copy of the advanced routing tools package (there is no shortcut for GRE tunnels in Linux 2.2 that I’ve been able to find). Once you have the iproute2 package installed, begin by loading the GRE kernel module on both routers:
# modprobe ip_greOn the first network’s router, set up a new tunnel device:
#ip tunnel add gre0 mode gre remote 251.4.92.217 local 240.101.83.2[RETURN]ttl 255#ip addr add 10.42.1.254 dev gre0#ip link set gre0 up
Note that you can call the device anything you like; gre0 is just an example. Also, that 10.42.1.254 address can be any available address on the first network, but shouldn’t be 10.42.1.1 (the IP already bound to its internal interface.) Now, add your network routes via the new tunnel interface:
# ip route add 10.42.2.0/24 ...