Tunneling network protocols—such as IP-in-IP (protocol 4) or Generic Routing Encapsulation (GRE, protocol 47)—is widely used across data centre interconnects, site-to-site bridges, and cloud virtualization fabrics. However, standard raw IP encapsulation protocols suffer from severe performance bottlenecks in modern multi-core server environments. Because IP-in-IP and GRE packets lack layer 4 transport port numbers (such as TCP/UDP ports), physical network interface controllers (NICs) cannot calculate hashing across multi-queue ring buffers. This breaks Receive Side Scaling (RSS) and Equal-Cost Multi-Path (ECMP) routing, forcing all encapsulated traffic onto a single CPU core.
To overcome this architectural limitation, the Linux kernel includes native support for Foo-over-UDP (FOU) and Generic UDP Encapsulation (GUE). Foo-over-UDP encapsulates arbitrary network payloads directly inside standard UDP datagrams. Because UDP packets possess dynamic source ports derived from the inner packet flows, physical NICs can distribute incoming tunnel packets across multiple CPU processing cores via hardware RSS, unlocking line-rate multi-gigabit throughput. Using iproute2, network engineers can configure FOU receiving listeners and attach encapsulated tunnel interfaces directly via the command line.
Understanding Foo-over-UDP (FOU) vs Generic UDP Encapsulation (GUE)
The Linux kernel supports two primary UDP encapsulation methods via the fou driver:
- Direct Foo-over-UDP (FOU): Appends a minimal 8-byte UDP header directly to the inner packet. The UDP destination port identifies the encapsulated protocol payload (e.g., binding port 5555 directly to IP-in-IP or GRE). This approach minimizes byte overhead and maximizes throughput.
- Generic UDP Encapsulation (GUE): Inserts a specialized GUE header between the UDP header and the encapsulated payload. The GUE header contains protocol type identifiers, security flags, and optional private metadata, allowing a single UDP port to multiplex diverse protocols.
Prerequisites and Kernel Module Loading
Foo-over-UDP requires a Linux kernel compiled with CONFIG_NET_FOU. Load the required kernel modules:
sudo modprobe fou
sudo modprobe ipip
Verify that the drivers are loaded into kernel memory:
lsmod | grep -E "fou|ipip"
To ensure persistent loading across reboots, add them to your system module configuration:
echo -e "fou\nipip" | sudo tee -a /etc/modules-load.d/fou.conf
Configuring an FOU Receiving Port Listener
Before a Linux server can receive and decapsulate Foo-over-UDP traffic, you must instruct the kernel networking stack to bind a listening UDP port to a specific IP protocol. This is accomplished using the ip fou add command.
To bind UDP port 5555 to receive raw IP-in-IP packets (IPv4 protocol 4):
sudo ip fou add port 5555 ipproto 4
To configure a port for Generic Routing Encapsulation (GRE, protocol 47) instead:
sudo ip fou add port 5556 ipproto 47
To inspect all active FOU listening ports registered with the kernel:
ip fou show
The console confirms the port and protocol association:
port 5555 ipproto 4
port 5556 ipproto 47
Creating an FOU-Encapsulated IPIP Tunnel Interface
Once the receiver listener is active, configure the virtual tunnel interface using ip link. In this example, Host A (192.168.1.10) connects to Host B (192.168.1.20) across an existing physical network.
On Host A, execute:
sudo ip link add name tun-fou0 type ipip \
remote 192.168.1.20 local 192.168.1.10 \
ttl 64 \
encap fou \
encap-sport auto \
encap-dport 5555 \
encap-csum
Parameter Explanations
type ipip: Specifies the underlying tunnel protocol.encap fou: Instructs the driver to wrap the IP-in-IP packet inside a UDP header.encap-sport auto: Generates a randomized, dynamic UDP source port based on the inner packet’s flow hash. This ensures that physical switches and NICs distribute different TCP/UDP connections across diverse RSS queues.encap-dport 5555: Targets the remote host’s configured FOU receiving port.encap-csum: Calculates and validates the UDP checksum for data integrity across intermediate routers.
Configuring IP Addressing and Bringing the Link Up
Assign private tunnel IP addresses to the virtual tun-fou0 interfaces:
On Host A:
sudo ip addr add 10.100.0.1/30 dev tun-fou0
sudo ip link set tun-fou0 up
On Host B:
# Set up listener
sudo ip fou add port 5555 ipproto 4
# Create reciprocal tunnel
sudo ip link add name tun-fou0 type ipip \
remote 192.168.1.10 local 192.168.1.20 \
ttl 64 \
encap fou \
encap-sport auto \
encap-dport 5555 \
encap-csum
# Assign IP and activate
sudo ip addr add 10.100.0.2/30 dev tun-fou0
sudo ip link set tun-fou0 up
Testing Connectivity and Verifying Multi-Core RSS Distribution
Test end-to-end communication across the tunnel:
ping -c 4 10.100.0.2
To verify that packets are wrapped in UDP headers, monitor physical interface traffic using tcpdump:
sudo tcpdump -ni eth0 udp port 5555
The capture displays standard UDP packets with varying source ports carrying the encapsulated tunnel payloads. During high-throughput iperf3 benchmarking, inspect /proc/interrupts to confirm that packet processing load is distributed evenly across all CPU cores.
Deleting FOU Tunnels and Listeners
When tearing down the tunnel infrastructure:
# Remove the virtual interface
sudo ip link delete tun-fou0
# Remove the kernel UDP port listener
sudo ip fou del port 5555
Foo-over-UDP combines the simplicity of native IP-in-IP tunneling with the hardware offload benefits of modern UDP networking, delivering maximum throughput on Linux systems.