From e80b1cfb826cf2926d0d87007b77cbd6639773b5 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 17 Nov 2026 03:21:39 +0000 Subject: host: names in tcp:// and udp:// rules The guests' DNS resolves every name to the host, so ssh somename went to the host, even with a rule for somename's address. Now the rules can take names, tcp://NAME:PORT[-PORT]: the firewall update resolves them on the host (IPv4) into the VM's set, and writes their addresses to a hosts file per tap in /run/fcbr0-hosts, which the guests' dnsmasq reads (--hostsdir; such entries win over address=/#/). A timer resolves them again every 5 minutes. dnsmasq can't tell guests apart, so every guest gets those addresses for those names, but only VMs whose list has the rule can connect. fcbr0-firewall now runs as a static user, fcbr0-firewall, which owns /run/fcbr0-hosts, and may use IPv4 and IPv6 sockets, for resolving. --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 4426412..04fc02f 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,7 @@ fc-egress list fc-egress allow cache.nixos.org # the domain and its subdomains fc-egress allow github.com/NixOS/ # only paths starting with /NixOS/ fc-egress allow tcp://192.0.2.7:22 # plain TCP to that address and port +fc-egress allow tcp://git.example.org:22 # or name (resolved by the host) fc-egress allow udp://192.0.2.0/24:5000-5100 fc-egress deny github.com/NixOS/ fc-egress -l work allow example.com # the list "work" @@ -123,9 +124,12 @@ when the guest gets built, so build the guest on the host after the proxy has started once. Everything else, and anything that isn't HTTPS, gets refused. -tcp:// and udp:// rules take IPv4 addresses (a guest resolves every name -to the host, so it has to use addresses for these, too). Those -connections get forwarded, NATed to the host's address, and logged +tcp:// and udp:// rules take IPv4 addresses or names. The guests +resolve every name to the host, except the names in such rules: the host +resolves those (IPv4) and tells the guests the same addresses, so +`ssh git.example.org` works. They get resolved again every 5 minutes. +(Every guest gets those addresses for those names, but only the VMs +whose list has the rule can connect.) Those connections get forwarded, NATed to the host's address, and logged (rate-limited, kernel log; `fc-egress log` shows them), as are refused ones. If the host has a forward chain of its own, it has to let them through, too (anything from -- cgit v1.3.1