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.
Principle
Section titled “Principle”br0bridge : 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.
-
A single MAC
In
etc/config.yaml,mackeeps 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. -
Declare the switch
usr/machines/srv/configuration.nix darkone.system.network.switch = {enable = true;uplink = "enp1s0f1";downlinks = ["enp1s0f0" # 10 GbE"enp2s0"];}; -
Apply on reboot
just apply srv boot, then reboot. Aswitchwould bring the uplink into the bridge while it is activating, and cut the SSH session. -
Check
ip -br addrshows the address onbr0,bridge linkthe bridge ports.
Do downstream machines lose the network?
Section titled “Do downstream machines lose the network?”Yes, while the host reboots (firmware, kernel). The bridge comes back from initrd, before the disk is unlocked.
Why a single MAC?
Section titled “Why a single MAC?”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.
What throughput to expect?
Section titled “What throughput to expect?”Bridged traffic goes through the host processor, and the uplink is shared with
its own exchanges. Measure end to end with iperf3.