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: a Linux subnet router needs IP forwarding turned on first

Linux
~/tips/tip-tailscale-subnet-router-ip-forwarding

echo 'net.ipv4.ip_forward = 1' | sudo tee -a /etc/sysctl.d/99-tailscale.conf

Enables IP forwarding for a Linux subnet router and shows how to advertise the routes.

Advertising a subnet with Tailscale looks like the whole job, and on Linux it isn’t. The kernel also has to be willing to forward packets. That setting is easy to forget, so here it is in one place.

The docs enable it through a sysctl drop-in file when /etc/sysctl.d exists:

echo 'net.ipv4.ip_forward = 1' | sudo tee -a /etc/sysctl.d/99-tailscale.conf
echo 'net.ipv6.conf.all.forwarding = 1' | sudo tee -a /etc/sysctl.d/99-tailscale.conf
sudo sysctl -p /etc/sysctl.d/99-tailscale.conf

Without that directory, the docs use /etc/sysctl.conf with the same lines. Then advertise the routes, as a comma-separated list:

sudo tailscale set --advertise-routes=192.0.2.0/24,198.51.100.0/24

Swap the example ranges for your own LAN. Advertising isn’t enough yet: the routes must be approved in the admin console (open the device, then its Subnets section, select the routes and save). They are approved automatically if the advertising user is covered by autoApprovers in your policy.

Two caveats from the same page. If the node runs firewalld, you might need to allow masquerading because of a known issue:

firewall-cmd --permanent --add-masquerade

And other Linux clients only discover new subnet routes automatically after sudo tailscale set --accept-routes. I’d check both when a route is approved but nothing answers on the far side.

Further reading: Subnet routers

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link