aboutsummaryrefslogtreecommitdiffstats
path: root/modules/host
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-17 01:43:46 +0000
committertv <tv@krebsco.de>2026-11-17 01:43:46 +0000
commit31611aa9bd7b39a4f700f1641bca2edb16619c64 (patch)
treeb49fbad5cb2220fdd558e4042cc26bc6aaac835d /modules/host
parentd281affea6d20c6569393f14624de06291303cb4 (diff)
host: keep the host's own NAT rules off the guests' connections
The host's NAT rules are for connections to the host, but they got applied to the guests', too: e.g. a redirect of port 11423 to the host's sshd turned a guest's allowed connection to some address's port 11423 into one to the host, which got rejected ("No route to host"). Our prerouting chain now runs before the host's, and gives everything from fcbr0 a NAT that changes nothing. A connection only ever gets one NAT, so the host's rules don't touch it any more.
Diffstat (limited to 'modules/host')
-rw-r--r--modules/host/default.nix10
1 files changed, 8 insertions, 2 deletions
diff --git a/modules/host/default.nix b/modules/host/default.nix
index 94a44b4..e2421c0 100644
--- a/modules/host/default.nix
+++ b/modules/host/default.nix
@@ -310,13 +310,19 @@ ${lib.concatMapStrings (u: ''
flags interval
}
'') userNames}
+ # Before the host's own NAT rules (which are for connections to the
+ # host, like a redirect of some port to its sshd), so they don't get
+ # applied to the guests' connections: the first NAT a connection gets
+ # is the only one, so everything else gets a NAT that changes
+ # nothing.
chain prerouting {
- type nat hook prerouting priority dstnat;
+ type nat hook prerouting priority dstnat - 1;
iifname "fcbr0" tcp dport 443 redirect to :${toString proxyPort}
+ iifname "fcbr0" meta nfproto ipv4 meta l4proto { tcp, udp } dnat ip to ip daddr
}
chain postrouting {
- type nat hook postrouting priority srcnat;
+ type nat hook postrouting priority srcnat - 1;
iifname "fcbr0" masquerade
}