Skip to content

ICMP redirects off by default (#21) - #55

Merged
Cd1s merged 1 commit into
mainfrom
fix/no-icmp-redirects
Sep 25, 2026
Merged

Cd1s merged 1 commit into
mainfrom
fix/no-icmp-redirects

Conversation

@Cd1s

@Cd1s Cd1s commented Sep 25, 2026

Copy link
Copy Markdown
Owner

What

/etc/sysctl.d/90-mini-router.conf now sets net.ipv4.conf.all.send_redirects=0 and net.ipv4.conf.default.send_redirects=0.

Why

When the router forwards a packet back out of the interface it arrived on (a static route to a LAN host, policy routing, the planned side-router mode), the kernel sends the client an ICMP redirect. Clients that follow it talk to the next hop directly: conntrack sees only the first packet, and access rules, traffic accounting and hardware flow offload stop applying. OpenWrt changed the same default (openwrt#24873).

Both keys are needed: the kernel sends a redirect when all or the netdev's own value is set. Writing default also copies the value to every existing netdev whose own value was never written, and netdevs created later (the LAN bridge, PPP links, WiFi) start from it.

Verification

  • On a running router (read only): every netdev had send_redirects=1, and no other sysctl file sets the key at boot (Alpine's 00-alpine.conf does not), so the boot run of this file reaches all of them.
  • CI, real kernel (tools/ci.d/sys.sh): in a network namespace, a dummy netdev created before and one created after loading the rendered file both end up with send_redirects=0 (with all and default). The check also documents a kernel detail found on the way: a netdev created after an earlier write to default inherits a "set" flag and would miss later changes of default.
  • Unit test for the rendered lines; tools/ci.sh passes (private and public trees).

Closes #21

https://claude.ai/code/session_01HWeUjo1dmS7gBkCYHrVjCr

A client that follows a redirect bypasses the router: conntrack, the firewall, accounting and flow
offload only see its first packet (static routes to LAN hosts, policy routing, side-router setups).
OpenWrt did the same (openwrt#24873).

- 90-mini-router.conf: net.ipv4.conf.{all,default}.send_redirects=0 — the kernel sends a redirect
  when all OR the netdev's value is set; default reaches existing netdevs never set on their own and
  every netdev created later.
- CI, real kernel: in a network namespace a netdev created before and one created after loading the
  rendered file both end up with send_redirects=0; unit test for the rendered lines.

Closes #21
@Cd1s
Cd1s merged commit 68f3c6c into main Sep 25, 2026
2 checks passed
@Cd1s
Cd1s deleted the fix/no-icmp-redirects branch September 25, 2026 16:50
@Cd1s Cd1s mentioned this pull request Sep 25, 2026
52 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

默认没有关闭 ICMP 重定向(send_redirects),会让 conntrack 和硬件卸载被绕开

1 participant