1 import ./make-test-python.nix ({ pkgs, lib, ... }: {
2 name = "containers-physical_interfaces";
4 maintainers = with lib.maintainers; [ kampfschlaefer ];
10 virtualisation.vlans = [ 1 ];
13 privateNetwork = true;
14 interfaces = [ "eth1" ];
17 networking.interfaces.eth1.ipv4.addresses = [
18 { address = "10.10.0.1"; prefixLength = 24; }
20 networking.firewall.enable = false;
25 virtualisation.vlans = [ 1 ];
27 containers.bridged = {
28 privateNetwork = true;
29 interfaces = [ "eth1" ];
32 networking.bridges.br0.interfaces = [ "eth1" ];
33 networking.interfaces.br0.ipv4.addresses = [
34 { address = "10.10.0.2"; prefixLength = 24; }
36 networking.firewall.enable = false;
42 virtualisation.vlans = [ 1 ];
45 privateNetwork = true;
46 interfaces = [ "eth1" ];
49 networking.bonds.bond0 = {
50 interfaces = [ "eth1" ];
51 driverOptions.mode = "active-backup";
53 networking.interfaces.bond0.ipv4.addresses = [
54 { address = "10.10.0.3"; prefixLength = 24; }
56 networking.firewall.enable = false;
61 bridgedbond = { ... }: {
62 virtualisation.vlans = [ 1 ];
64 containers.bridgedbond = {
65 privateNetwork = true;
66 interfaces = [ "eth1" ];
69 networking.bonds.bond0 = {
70 interfaces = [ "eth1" ];
71 driverOptions.mode = "active-backup";
73 networking.bridges.br0.interfaces = [ "bond0" ];
74 networking.interfaces.br0.ipv4.addresses = [
75 { address = "10.10.0.4"; prefixLength = 24; }
77 networking.firewall.enable = false;
86 with subtest("Prepare server"):
87 server.wait_for_unit("default.target")
88 server.succeed("ip link show dev eth1 >&2")
90 with subtest("Simple physical interface is up"):
91 server.succeed("nixos-container start server")
92 server.wait_for_unit("container@server")
94 "systemctl -M server list-dependencies network-addresses-eth1.service >&2"
97 # The other tests will ping this container on its ip. Here we just check
98 # that the device is present in the container.
99 server.succeed("nixos-container run server -- ip a show dev eth1 >&2")
101 with subtest("Physical device in bridge in container can ping server"):
102 bridged.wait_for_unit("default.target")
103 bridged.succeed("nixos-container start bridged")
104 bridged.wait_for_unit("container@bridged")
106 "systemctl -M bridged list-dependencies network-addresses-br0.service >&2",
107 "systemctl -M bridged status -n 30 -l network-addresses-br0.service",
108 "nixos-container run bridged -- ping -w 10 -c 1 -n 10.10.0.1",
111 with subtest("Physical device in bond in container can ping server"):
112 bonded.wait_for_unit("default.target")
113 bonded.succeed("nixos-container start bonded")
114 bonded.wait_for_unit("container@bonded")
116 "systemctl -M bonded list-dependencies network-addresses-bond0 >&2",
117 "systemctl -M bonded status -n 30 -l network-addresses-bond0 >&2",
118 "nixos-container run bonded -- ping -w 10 -c 1 -n 10.10.0.1",
121 with subtest("Physical device in bond in bridge in container can ping server"):
122 bridgedbond.wait_for_unit("default.target")
123 bridgedbond.succeed("nixos-container start bridgedbond")
124 bridgedbond.wait_for_unit("container@bridgedbond")
126 "systemctl -M bridgedbond list-dependencies network-addresses-br0.service >&2",
127 "systemctl -M bridgedbond status -n 30 -l network-addresses-br0.service",
128 "nixos-container run bridgedbond -- ping -w 10 -c 1 -n 10.10.0.1",