How to configure gre-over-udp on Linux
How to setup a gre-over-udp tunnel on Linux is something I have learned and
forgotten a few times now. So here is how you do it.
- modprobe the fou kernel module, distro's don't seem to load the one by
default.
modprobe fou
indicate that anything recieved on udp port 4754 is General Routing
Ecapsulation (GRE) (ipproto 47).
Remember that UDP header supplies no information about the encapsulated frame,
this command is how we tell linux to interpret anything that arrives on udp
port 4754 as GRE.
ip fou add port 4754 ipproto 47
- create a new interface called `fou0`, as the local endpoint of the gre
tunnel.
- <remote-ip> is the ip address of the other side of the tunnel.
- <remove-dport> is the udp port of the other side of the tunnl, should be
udp port 4754.
- <remote-ip> is the ip address of the other side of the tunnel.
ip link add name fou0 type gre remote <remote-ip> encap fou encap-sport auto encap-dport <remote-dport> dev eth0
- add the ip ranges that run over the overlay interface `fou0`, by adding an ip
address and mask to the overlay interface.
ip addr add 100.100.1.1/16 dev fou0
- set the tunnel state to up, this will enable the interface and add the routes
to the kernels routing table.
ip link set up dev fou0
- ping across the overlay, to ensure everything is working as expected.
$ sudo tcpdump -vi <interface> dropped privs to tcpdump tcpdump: listening on <interface>, link-type EN10MB (Ethernet), snapshot length 262144 bytes 18:25:40.018795 IP (tos 0x0, ttl 64, id 10744, offset 0, flags [DF], proto UDP (17), length 116) 10.11.1.2.40734 > 10.11.2.2.gre-in-udp: UDP, length 88 18:25:40.018850 IP (tos 0x0, ttl 62, id 16735, offset 0, flags [DF], proto UDP (17), length 116) 10.11.2.2.40734 > 10.11.1.2.gre-in-udp: UDP, length 88
networking