ZeroTierOne icon indicating copy to clipboard operation
ZeroTierOne copied to clipboard

Stale socket after interface is recreated with the same IP (Linux)

Open gongtao0607 opened this issue 1 month ago • 0 comments

What you expect to be happening

When the network interface is recreated with the same IP (e.g. a PPPoE reconnect), ZeroTier keeps working.

What is actually happening

ZeroTier stops sending and receiving on that interface until it is restarted. Nothing is logged, and zerotier-cli info still says ONLINE. Peers go RELAY or offline.

The UDP socket is still bound to the right IP and port, but the kernel no longer matches it: incoming packets get ICMP port unreachable, and nothing goes out.

If the interface comes back with a different IP, ZeroTier recovers by itself.

Likely cause

osdep/Binder.hpp, refresh(): on Linux each socket is bound to its interface with SO_BINDTODEVICE (stored as an ifindex). On refresh, it keeps an existing binding as long as its IP address is still present on the system . It doesn't check whether the interface behind that address is still the same one.

When the interface is deleted and created again (PPPoE reconnect, veth recreate, etc.), it gets a new ifindex. If the IP comes back the same, refresh() sees the address and keeps the old socket. That socket is still bound to the old ifindex, which no longer exists

Possible fix: also rebind when the ifindex for the interface name changes.

Steps to reproduce

  1. Linux host running zerotier-one with peers DIRECT.
  2. Delete and recreate the interface with the same IP (e.g. a veth in a netns, or a PPPoE reconnect that gets the same IP).
  3. Wait 30+ seconds. tcpdump on the interface shows no ZeroTier traffic, and a UDP packet sent to the node's port 9993 gets ICMP port unreachable.
  4. Restart zerotier-one, and it works again.

Workaround

Restart zerotier-one when the interface comes up.

OS and version

  • ZeroTier 1.16.2 on Arch Linux (reproduced with a veth in a network namespace)
  • ZeroTier 1.14.1 on OpenWrt 23.05.2 (PPPoE WAN)

gongtao0607 avatar Oct 11 '26 06:10 gongtao0607