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

+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.