beefcake: NAT tailscale0 so exit-node traffic gets masqueraded #540
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "beefcake-exit-node-nat"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
With beefcake serving as a Tailscale exit node, clients' traffic was egressing
eno1with the tailnet source IP unchanged (e.g.100.64.0.9from the Zenfone), so internet replies had no return path — conntrack stayed[UNREPLIED]on every flow and pages like lobste.rs would just hang from the phone.Root cause: beefcake runs
tailscaledwithNetfilterMode=0(deliberate — keeps it from stomping on the k3s / flannel / netavark rules also installed on this host), which means Tailscale doesn't install its ownMASQUERADErule for exit-node traffic. The existingnetworking.natconfig only marksve-+(nixos-containers) traffic for masquerading, nottailscale0.Fix: add
tailscale0tonetworking.nat.internalInterfaces. NixOS's existingnixos-nat-prechain then marks tailscale-arriving packets with0x1, and thenixos-nat-postMASQUERADE ... out eno1 mark match 0x1rule rewrites the source to beefcake's LAN IP.Test plan
SYN_SENT src=100.64.0.9 dst=151.101.65.140 [UNREPLIED]for every flow from the phone.iptables -t nat -A nixos-nat-pre -i tailscale0 -j MARK --set-xmark 0x1) — lobste.rs and other sites load immediately from the phone with beefcake as exit node.nixos-rebuild switch) so the rule persists across reboots.iptables -t nat -L nixos-nat-pre -v -nshows thetailscale0 -> MARK 0x1rule.Security posture
tag:admindevicenodes (which already have*:*coveringautogroup:internet) can actually use the exit node;group:family/group:friendslack any rule permittingautogroup:internet:*so they couldn't route through it even if they tried.eno1traffic that was originally marked fromtailscale0— doesn't affect any inbound or LAN-internal flows.10fce701c7a3d55b3093