Archived
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e9b225d2d6 | ||
|
|
781b1d324e | ||
|
|
cda2132d6a | ||
|
|
6c1cc821a0 |
@@ -1,4 +1,4 @@
|
|||||||
{ ... }:
|
{ vars, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
@@ -12,8 +12,31 @@
|
|||||||
# own setting) so the intent is clear at the build-type level.
|
# own setting) so the intent is clear at the build-type level.
|
||||||
services.tailscale.useRoutingFeatures = "server";
|
services.tailscale.useRoutingFeatures = "server";
|
||||||
|
|
||||||
# Forwarded subnet-router traffic arrives on tailscale0 already
|
# Advertise the LAN subnet so Tailscale peers can route back to LAN machines.
|
||||||
# tailscale-authenticated -- the firewall's normal per-port allow-list
|
# Must also be approved in the Tailscale admin console (Machines → Edit route settings).
|
||||||
# would otherwise drop it. Standard NixOS/Tailscale subnet-router guidance.
|
services.tailscale.extraUpFlags = [ "--advertise-routes=${vars.lanCidr}" ];
|
||||||
networking.firewall.trustedInterfaces = [ "tailscale0" ];
|
|
||||||
|
networking.firewall = {
|
||||||
|
# Forwarded subnet-router traffic arrives on tailscale0 already
|
||||||
|
# tailscale-authenticated -- the firewall's normal per-port allow-list
|
||||||
|
# would otherwise drop it. Standard NixOS/Tailscale subnet-router guidance.
|
||||||
|
trustedInterfaces = [ "tailscale0" ];
|
||||||
|
|
||||||
|
# SNAT LAN traffic going into Tailscale so the remote peer sees it as
|
||||||
|
# coming from this router's Tailscale IP rather than a raw LAN IP.
|
||||||
|
# Without this, Tailscale drops forwarded packets whose source is not a
|
||||||
|
# recognised Tailscale address.
|
||||||
|
#
|
||||||
|
# We target POSTROUTING directly (always-existing built-in chain) rather
|
||||||
|
# than nixos-nat-post: extraCommands runs after the old nixos-nat-post is
|
||||||
|
# deleted but before the new one is created, so -A nixos-nat-post silently
|
||||||
|
# fails. The -C check makes the rule idempotent across firewall reloads.
|
||||||
|
extraCommands = ''
|
||||||
|
iptables -t nat -C POSTROUTING -s ${vars.lanCidr} -o tailscale0 -j MASQUERADE 2>/dev/null || \
|
||||||
|
iptables -t nat -A POSTROUTING -s ${vars.lanCidr} -o tailscale0 -j MASQUERADE
|
||||||
|
'';
|
||||||
|
extraStopCommands = ''
|
||||||
|
iptables -t nat -D POSTROUTING -s ${vars.lanCidr} -o tailscale0 -j MASQUERADE 2>/dev/null || true
|
||||||
|
'';
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user