safer bridge mode

This commit is contained in:
ari committed 2026-09-23 19:29:28 -04:00
1 parent b5d59c34ac
commit d5afd6510f
7 files changed
+337 -120

No files matched your search

+5 -3
View File
@@ -182,9 +182,11 @@ in
# onto the LAN (services.hermenix.network.bridged = true on the host).
# - NAT mode: no DHCP server on the host bridge; the static default
# route via the host is the only one and carries all traffic.
# - bridged mode: the LAN's DHCP leases this NIC a real LAN address;
# that lease's lower-metric default route (100) wins over the static
# fallback (200), and LAN devices reach the VM at the lease address.
# - bridged mode: the host runs a DHCP server on its bridge that hands
# this NIC its fixed LAN address (services.hermenix.network.lanAddress,
# keyed to this NIC's MAC); that lease's lower-metric default route
# (100) wins over the static fallback (200), and LAN devices reach
# the VM at the fixed address. The VM never needs to know the address.
# Resolvers stay QUAD9 (UseDNS = false) in both modes.
# =====================================================================
networking.useNetworkd = true;
+4 -3
View File
@@ -25,9 +25,10 @@ changes persist across reboots.
the cheapest undo available to you, and future-you will want it.
- If you break the system badly enough that you cannot fix it, the operator
has snapshots of the state disk. Say so plainly rather than thrashing.
- You have no route to the host or the local network unless the operator has
opened a specific port. If something is unreachable, that is probably
deliberate — ask rather than working around it.
- Reachability is gated on the host: what you can reach from here is
allowlisted (lanAccess/allowLan), in both network modes. If something is
unreachable, that is probably deliberate — ask rather than working around
it.
## What I care about
+1 -1
View File
@@ -4,7 +4,7 @@
# The guest node's configuration and every assertion that must hold in both
# networking modes are defined here, once; each mode test imports this file,
# uses guestNode as its machine, and appends only the checks that apply to
# its mode (the isolated-bridge NAT setup vs. the DHCP-served LAN bridge).
# its mode (the isolated-bridge NAT setup vs. the fixed-address LAN bridge).
#
# Both tests boot guest/common.nix — the same module set hermes-guest-image
# is built from — in an ephemeral, throwaway NixOS test VM. No real disk
+18 -15
View File
@@ -1,9 +1,11 @@
# Guest-config VM test, bridged mode: the guest on a LAN served by DHCP,
# with a second node acting as the LAN (a DHCP server, a throwaway HTTP
# service, and a plain device that connects back to the guest). This is the
# guest-facing half of services.hermenix.network.bridged = true: the module's
# own bridge/enforcement rules are covered statically by
# tests/network-modes-check.nix.
# Guest-config VM test, bridged mode: the guest on a LAN that hands it one
# fixed address (the production shape of services.hermenix.network.bridged
# = true: the host-side DHCP server reserves lanAddress for the guest's MAC,
# so the guest is effectively static without knowing it). A second node acts
# as the LAN: the reservation-style DHCP server, a throwaway HTTP service,
# and a plain device that connects back to the guest. This is the
# guest-facing half of the module; the module's own bridge/enforcement rules
# are covered statically by tests/network-modes-check.nix.
#
# The guest node and the mode-independent assertions (seeding, idempotency,
# account, SSH) are shared with guest-vm-unbridged via
@@ -27,10 +29,10 @@ pkgs.testers.runNixOSTest {
nodes = {
machine = common.guestNode;
# The "LAN": serves DHCP to the guest and hosts a throwaway HTTP
# service, standing in for the LAN router and another LAN device. Its
# firewall is off so the guest<->LAN checks exercise the network path
# itself, not this throwaway node's own firewall.
# The "LAN": hands the guest its single fixed address and hosts a
# throwaway HTTP service, standing in for the router and another LAN
# device. Its firewall is off so the guest<->LAN checks exercise the
# network path itself, not this throwaway node's own firewall.
lan =
{ pkgs, lib, ... }:
{
@@ -63,7 +65,9 @@ pkgs.testers.runNixOSTest {
networkConfig.LinkLocalAddressing = "no";
};
# DHCP only (port = 0 disables dnsmasq's DNS half; the guest keeps
# DHCP only, and reservation-style: a single-address range, exactly
# how the host-side hermes-lan-dhcp hands the real guest its fixed
# lanAddress (port = 0 disables dnsmasq's DNS half; the guest keeps
# its own QUAD9 resolvers regardless). Bound to the node's static
# vlan address rather than an interface name - the framework's
# interface naming is not something this test should depend on.
@@ -73,10 +77,9 @@ pkgs.testers.runNixOSTest {
port = 0;
listen-address = "192.168.1.2";
bind-interfaces = true;
dhcp-range = "192.168.1.100,192.168.1.200,12h";
dhcp-range = "192.168.1.100,192.168.1.100,12h";
dhcp-option = [
"3,192.168.1.2" # default gateway -> this node
"6,192.168.1.2" # DNS -> this node
];
};
};
@@ -93,7 +96,7 @@ pkgs.testers.runNixOSTest {
+ common.commonScript
+ ''
# --- bridged-mode networking ---------------------------------------
# The LAN's DHCP gave the guest a lease alongside its static
# The LAN handed the guest its fixed address alongside its static
# service-net address. (Both test nodes share one vlan, standing in for
# the bridged uplink on a real host.)
machine.wait_until_succeeds("ip -4 route show default | grep -q 'metric 100'")
@@ -105,7 +108,7 @@ pkgs.testers.runNixOSTest {
if not ip.startswith("10.77."):
guest_lan_ip = ip
assert any("10.77.0.2/24" in line for line in addrs), f"static service-net address missing in bridged mode: {addrs}"
assert guest_lan_ip is not None, f"guest never took a LAN DHCP lease: {addrs}"
assert guest_lan_ip == "192.168.1.100", f"guest should have been handed its fixed LAN address, got: {addrs}"
# Both default routes are in place: the LAN's (metric 100, in use) and
# the host service-net fallback (metric 200) that NAT mode relies on.