1 # This test predominantly tests systemd-networkd DHCP server, by
2 # setting up a DHCP server and client, and ensuring they are mutually
3 # reachable via the DHCP allocated address.
4 # Two DHCP servers are set up on bridge VLANs, testing to make sure that
5 # bridge VLAN settings are correctly applied.
8 # +---PVID 1+VLAN 2---[bridge]---PVID 2---eth1
10 import ./make-test-python.nix ({pkgs, ...}: {
11 name = "systemd-networkd-dhcpserver";
12 meta = with pkgs.lib.maintainers; {
16 router = { config, pkgs, ... }: {
17 virtualisation.vlans = [ 1 ];
18 systemd.services.systemd-networkd.environment.SYSTEMD_LOG_LEVEL = "debug";
22 firewall.enable = false;
48 # systemd-networkd will load the first network unit file
49 # that matches, ordered lexiographically by filename.
50 # /etc/systemd/network/{40-eth1,99-main}.network already
51 # exists. This network unit must be loaded for the test,
52 # however, hence why this network is named such.
55 networkConfig.Bridge = "br0";
57 { bridgeVLANConfig = { PVID = 2; EgressUntagged = 2; }; }
64 Address = "10.0.0.1/24";
72 { bridgeVLANConfig = { PVID = 1; EgressUntagged = 1; }; }
73 { bridgeVLANConfig = { VLAN = 2; }; }
80 Address = "10.0.2.1/24";
91 client = { config, pkgs, ... }: {
92 virtualisation.vlans = [ 1 ];
93 systemd.services.systemd-networkd.environment.SYSTEMD_LOG_LEVEL = "debug";
97 firewall.enable = false;
98 interfaces.eth1.useDHCP = true;
102 testScript = { ... }: ''
104 router.wait_for_unit("systemd-networkd-wait-online.service")
105 client.wait_for_unit("systemd-networkd-wait-online.service")
106 client.wait_until_succeeds("ping -c 5 10.0.2.1")
107 router.wait_until_succeeds("ping -c 5 10.0.2.100")