Skip to content
This repository was archived by the owner on Apr 28, 2026. It is now read-only.

Commit 4a1275d

Browse files
committed
nix: cleanup guest network config
This makes the guest network config a bit easier (no unnecessary udev rules anymore). Also, this gets rid of some sporadic errors with interfaces losing their config. E.g. the second interface of the Cloud Hypervisor guest (192.168.2.2) would sometimes lose its IP address after a live migration with the old config. This doesn't happen anymore (or at least a lot less often). On-behalf-of: SAP sebastian.eydam@sap.com Signed-off-by: Sebastian Eydam <sebastian.eydam@cyberus-technology.de>
1 parent 05dd4ac commit 4a1275d

1 file changed

Lines changed: 27 additions & 53 deletions

File tree

‎images/nixos-image.nix‎

Lines changed: 27 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -89,38 +89,36 @@ nixpkgs.lib.nixosSystem {
8989
# Please keep in sync with documentation in networks.md!
9090
networking.firewall.enable = false;
9191
networking.hostName = "nixos";
92-
networking.interfaces.eth1337.ipv4.addresses = [
93-
{
94-
address = "192.168.1.2";
95-
prefixLength = 24;
96-
}
97-
];
98-
networking.interfaces.eth1337.useDHCP = false;
99-
networking.interfaces.eth1338.ipv4.addresses = [
100-
{
101-
address = "192.168.2.2";
102-
prefixLength = 24;
103-
}
104-
];
105-
networking.interfaces.eth1338.useDHCP = false;
106-
networking.interfaces.eth1339.ipv4.addresses = [
107-
{
108-
address = "192.168.3.2";
109-
prefixLength = 24;
110-
}
111-
];
112-
networking.interfaces.eth1339.useDHCP = false;
113-
networking.interfaces.eth1340.ipv4.addresses = [
114-
{
115-
address = "192.168.4.2";
116-
prefixLength = 24;
117-
}
118-
];
119-
networking.interfaces.eth1340.useDHCP = false;
120-
12192
networking.useDHCP = false;
93+
networking.networkmanager.enable = lib.mkForce false;
12294
networking.useNetworkd = true;
12395

96+
systemd.network = {
97+
enable = true;
98+
networks = {
99+
eth1337 = {
100+
matchConfig.MACAddress = "52:54:00:e5:b8:01";
101+
address = [ "192.168.1.2/24" ];
102+
linkConfig.RequiredForOnline = "no";
103+
};
104+
eth1338 = {
105+
matchConfig.MACAddress = "52:54:00:e5:b8:02";
106+
address = [ "192.168.2.2/24" ];
107+
linkConfig.RequiredForOnline = "no";
108+
};
109+
eth1339 = {
110+
matchConfig.MACAddress = "52:54:00:e5:b8:03";
111+
address = [ "192.168.3.2/24" ];
112+
linkConfig.RequiredForOnline = "no";
113+
};
114+
eth1340 = {
115+
matchConfig.MACAddress = "52:54:00:e5:b8:04";
116+
address = [ "192.168.4.2/24" ];
117+
linkConfig.RequiredForOnline = "no";
118+
};
119+
};
120+
};
121+
124122
nix.enable = false;
125123

126124
programs = {
@@ -146,35 +144,11 @@ nixpkgs.lib.nixosSystem {
146144
services.logrotate.enable = false;
147145
services.resolved.enable = false;
148146
services.timesyncd.enable = false;
149-
services.udev.extraRules = ''
150-
# Stable NIC name for the default VM network.
151-
ACTION=="add", SUBSYSTEM=="net", \
152-
ATTR{address}=="52:54:00:e5:b8:01", \
153-
NAME="eth1337"
154-
155-
# Stable NIC name for hotplugged network (type 'ethernet').
156-
ACTION=="add", SUBSYSTEM=="net", \
157-
ATTR{address}=="52:54:00:e5:b8:02", \
158-
NAME="eth1338"
159-
160-
# Stable NIC name for hotplugged network #2 (type 'network').
161-
ACTION=="add", SUBSYSTEM=="net", \
162-
ATTR{address}=="52:54:00:e5:b8:03", \
163-
NAME="eth1339"
164-
165-
# Stable NIC name for hotplugged network #2 (type 'network').
166-
ACTION=="add", SUBSYSTEM=="net", \
167-
ATTR{address}=="52:54:00:e5:b8:04", \
168-
NAME="eth1340"
169-
'';
170147
services.udisks2.enable = false;
171148

172149
system.stateVersion = "25.05";
173150
system.switch.enable = false;
174151

175-
systemd.network.wait-online.ignoredInterfaces = [
176-
"eth1337"
177-
];
178152
systemd.services.mount-pstore.enable = false;
179153
systemd.services.resolvconf.enable = false;
180154
# We use a dummy key for the test VM to shortcut the boot time.

0 commit comments

Comments
 (0)