brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: turn off ICMP redirects on a server, a sysctl security setting most hosts never need

Security
~/tips/tip-security-sysctl-accept-redirects

sysctl -a 2>/dev/null | grep -E 'accept_redirects|send_redirects'

Stops the server from changing its routes because of ICMP redirect messages.

An ICMP redirect tells a host to send traffic for some address through a different gateway. On a network you don’t fully trust, that is a neat way to reroute traffic, and a server with a fixed route has no use for it.

Check the current values first:

sysctl -a 2>/dev/null | grep -E 'accept_redirects|send_redirects'

Then switch them off in a file under /etc/sysctl.d/:

net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0

Load it with sudo sysctl --system. The kernel docs explain why the example sets both all and default: on a host that does not forward packets, redirects are accepted when either the all value or the interface value is on. default covers interfaces created later, such as a VPN tunnel or a Docker bridge. Interfaces that already exist keep their own value until you set it or reboot.

The send_redirects lines matter only if the box routes traffic. I’d leave them alone on a router where you actually want redirects sent. On a normal single server you lose nothing, since it has one gateway and should stick to it.

Further reading: Linux kernel documentation: IP sysctl

More Security tips tcpdump -nn -r capture.pcap port 53 mkcert -install Strict-Transport-Security: max-age=0 Referrer-Policy: strict-origin-when-cross-origin wp super-admin list All Security tips (79) All topics

Link