From 31611aa9bd7b39a4f700f1641bca2edb16619c64 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 17 Nov 2026 01:43:46 +0000 Subject: 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. --- modules/host/default.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'modules/host') 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 } -- cgit v1.3.1