aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-16 21:43:46 +0000
committertv <tv@krebsco.de>2026-11-16 21:43:46 +0000
commit2af6a48f296aa24e1a6e8670e4f5784fe28c9ea4 (patch)
treec9cc0a26a14412c52948b04bddb8d90ae71177ea
parent0d9bdecb42cb491584923f870a07a92d851dde23 (diff)
host: only let the guests reach dnsmasq and nginx
Nothing got forwarded, but the host itself was wide open to the guests: its own services (sshd, ...) at 172.16.0.1, where DNS sends every name, or any of its other addresses, and ICMP. Now the input chain rejects everything from fcbr0 but DHCP and DNS to dnsmasq and the redirected TLS to nginx. And a bridge table drops frames between the taps, so the guests can't talk to each other either.
-rw-r--r--host.nix29
1 files changed, 27 insertions, 2 deletions
diff --git a/host.nix b/host.nix
index 23b8450..d28b3d6 100644
--- a/host.nix
+++ b/host.nix
@@ -204,8 +204,14 @@ in {
# with scripted networking, which assigns it regardless.)
systemd.network.networks."40-fcbr0".networkConfig.ConfigureWithoutCarrier = true;
- # forward only rejects; for anything else the host's own forward chain
- # decides. redirect sends the guests' TLS to nginx, see above.
+ # What the guests may do on the host's network: DHCP and DNS with our
+ # dnsmasq, and TLS to nginx (port 443 of any address, redirected to
+ # 172.16.0.1:proxyPort). Nothing else, neither to the host (whose own
+ # services, like ssh, the guests would otherwise reach at 172.16.0.1,
+ # where DNS sends every name, or at any other of its addresses) nor
+ # through it (nothing gets forwarded), nor to each other (bridge).
+ # These chains only reject; for what they let through, the host's own
+ # chains decide, too.
networking.nftables.enable = true;
networking.nftables.tables.firecracker = {
family = "inet";
@@ -215,12 +221,31 @@ in {
iifname "fcbr0" tcp dport 443 redirect to :${toString proxyPort}
}
+ chain input {
+ type filter hook input priority filter; policy accept;
+ iifname != "fcbr0" accept
+ ct state { established, related } accept
+ ip daddr { 172.16.0.1, 255.255.255.255 } udp dport 67 accept
+ ip daddr 172.16.0.1 udp dport 53 accept
+ ip daddr 172.16.0.1 tcp dport { 53, ${toString proxyPort} } accept
+ reject with icmpx admin-prohibited
+ }
+
chain forward {
type filter hook forward priority filter; policy accept;
iifname "fcbr0" reject with icmpx admin-prohibited
}
'';
};
+ networking.nftables.tables.firecracker-bridge = {
+ family = "bridge";
+ content = ''
+ chain forward {
+ type filter hook forward priority filter; policy accept;
+ iifname "fctap*" oifname "fctap*" drop
+ }
+ '';
+ };
# A dnsmasq of its own, so it doesn't get mixed up with one the host might
# run otherwise. DHCP, and DNS that resolves every name to 172.16.0.1