Skip to main content

Fix ICMP Redirect

将 gateway 设置为同一网段中的非 .1 的 IP 时 (有些人称之为旁路由/旁路网关),我们有时会看到一条 error Redirect Host(New nexthop: 10.0.1.1)

% ping -n baidu.com
PING baidu.com (39.156.66.10) 56(84) bytes of data.
From 10.0.1.17 icmp_seq=1 Redirect Host(New nexthop: 10.0.1.1)
64 bytes from 39.156.66.10: icmp_seq=1 ttl=49 time=18.7 ms
64 bytes from 39.156.66.10: icmp_seq=2 ttl=49 time=19.0 ms
64 bytes from 39.156.66.10: icmp_seq=3 ttl=49 time=19.5 ms
64 bytes from 39.156.66.10: icmp_seq=4 ttl=49 time=18.3 ms

只需要在你的网关上用 sysctl 设置 net.ipv4.conf.all.send_redirects=0 即可

sudo sysctl -w net.ipv4.conf.all.send_redirects=0