Skip to content

Turning a host into a switch

A host can lend its free network ports to its zone. A machine plugged into it is in the zone as if behind a hardware switch : gateway DHCP and DNS, no configuration on its side.

Diagram
  • br0 bridge : groups the uplink (to the zone) and the downlinks (free ports).
  • Host address : carried by br0, via DHCP, with the uplink’s MAC.
  • Pure layer 2 : no STP, no filtering by the host firewall.
  • From initrd onwards : the downstream side keeps the network while waiting for LUKS unlock.

The host switches to systemd-networkd. A zone gateway or a host running NetworkManager cannot be switched : the evaluation refuses it.

  1. A single MAC

    In etc/config.yaml, mac keeps only the uplink address : the bridge takes it over, the DHCP reservation follows the bridge.

    etc/config.yaml
    - hostname: "srv"
    zone: "maison:1.2"
    mac: "02:00:00:00:00:01"

    Then just generate.

  2. Declare the switch

    usr/machines/srv/configuration.nix
    darkone.system.network.switch = {
    enable = true;
    uplink = "enp1s0f1";
    downlinks = [
    "enp1s0f0" # 10 GbE
    "enp2s0"
    ];
    };
  3. Apply on reboot

    just apply srv boot, then reboot. A switch would bring the uplink into the bridge while it is activating, and cut the SSH session.

  4. Check

    ip -br addr shows the address on br0, bridge link the bridge ports.

Yes, while the host reboots (firmware, kernel). The bridge comes back from initrd, before the disk is unlocked.

The bridge must take over the uplink address, and the evaluation cannot guess which of the MACs it is. Several MACs or none → the evaluation fails.

Can two ports be linked to the same switch?

Section titled “Can two ports be linked to the same switch?”

No : without STP, two ports on the same segment form a loop.

Bridged traffic goes through the host processor, and the uplink is shared with its own exchanges. Measure end to end with iperf3.