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 { PVID = 2; EgressUntagged = 2; }
64 Address = "10.0.0.1/24";
72 { PVID = 1; EgressUntagged = 1; }
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 = { ... }: ''
105 router.systemctl("start network-online.target")
106 client.systemctl("start network-online.target")
107 router.wait_for_unit("systemd-networkd-wait-online.service")
108 client.wait_for_unit("systemd-networkd-wait-online.service")
109 client.wait_until_succeeds("ping -c 5 10.0.2.1")
110 router.wait_until_succeeds("ping -c 5 10.0.2.100")