Some Bits: Nelson's log

Linux: Multihoming and ARP lies

TIL Linux follows the weak host model of multi-homing. If a Linux machine has more than one network adapter and more than one IP address, it assumes all the addresses belong to the one Linux machine and will gladly accept IP traffic on all those interfaces.

Big surprise to me! I always thought multihoming worked on a per-device notion. In the typical case every interface has its own device name, a MAC address for the device, and an IP address for the device. Nope! A device may get packets sent to it for IP addresses it doesn’t own.

The term “weak model” come from RFC 1122, from 1989. This is not a new idea!

The Linux behavior is on purpose, supposedly because it makes it more likely you can reach a host in case things are a bit wonky. It’s also configurable: if you set arp_ignore to 1 it will “reply only if the target IP address is local address configured on the incoming interface”

WiFi vs Ethernet

I ran into this problem when I gave my Linux desktop a WiFi connection on my LAN in addition to the usual ethernet. For simplicity, let’s say the ethernet is on 192.168.3.10 and the wifi is on .11. Packets go out via the ethernet on .10 because that interface has a higher priority in the routing table. But other devices replying with packets for .10 may send them on the WiFi rather than the ethernet.

Why? Because Linux lies. If an ARP request shows up saying “who has .10 the WiFi adapter will proudly say “I do I do!” injecting its MAC address in everyone else’s ARP cache, despite the adapter not being configured for that address. And packets that show up on the WiFi for .10 will be accepted by the Linux device that’s configured to receive packets on .11. Crazy.

I guess it’s been like this all the time and I haven’t noticed. It seems to cause a practical problem right away though, any machine with both wired and wireless interfaces is randomly using the WiFi without meaning to. I think that’d be a big problem for docked laptops! Maybe no-one notices.

The fact I’ve gone 20+ years without knowing this suggests it may not cause that many problems. Still confusing to me.