From bdc79efc2b1e1eb4503589e6c362ccc9e10e9298 Mon Sep 17 00:00:00 2001 From: Adam Stephens Date: Sun, 11 Feb 2024 14:28:14 -0500 Subject: [PATCH 1/2] nixos/lxd/vm: fix network config --- .../scripts/lxd/lxd-virtual-machine-image-inner.nix | 7 ++++--- .../maintainers/scripts/lxd/lxd-virtual-machine-image.nix | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/nixos/maintainers/scripts/lxd/lxd-virtual-machine-image-inner.nix b/nixos/maintainers/scripts/lxd/lxd-virtual-machine-image-inner.nix index 2d1761401fcd..d1264fa04304 100644 --- a/nixos/maintainers/scripts/lxd/lxd-virtual-machine-image-inner.nix +++ b/nixos/maintainers/scripts/lxd/lxd-virtual-machine-image-inner.nix @@ -14,14 +14,15 @@ ]; networking = { - dhcdpcd.enable = false; + dhcpcd.enable = false; useDHCP = false; + useHostResolvConf = false; }; systemd.network = { enable = true; - networks."50-eth0" = { - matchConfig.Name = "eth0"; + networks."50-enp5s0" = { + matchConfig.Name = "enp5s0"; networkConfig = { DHCP = "ipv4"; IPv6AcceptRA = true; diff --git a/nixos/maintainers/scripts/lxd/lxd-virtual-machine-image.nix b/nixos/maintainers/scripts/lxd/lxd-virtual-machine-image.nix index a58579914465..bbbdd1f3fa17 100644 --- a/nixos/maintainers/scripts/lxd/lxd-virtual-machine-image.nix +++ b/nixos/maintainers/scripts/lxd/lxd-virtual-machine-image.nix @@ -27,8 +27,9 @@ # Network networking = { - dhcdpcd.enable = false; + dhcpcd.enable = false; useDHCP = false; + useHostResolvConf = false; }; systemd.network = { From cf68af8561b4624738f10158960ce2748fa75877 Mon Sep 17 00:00:00 2001 From: Adam Stephens Date: Sun, 11 Feb 2024 14:28:31 -0500 Subject: [PATCH 2/2] nixos/lxc/container: switch to networkd by default --- .../scripts/lxd/lxd-container-image-inner.nix | 19 ++++++++++++++++-- .../scripts/lxd/lxd-container-image.nix | 20 ++++++++++++++++--- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/nixos/maintainers/scripts/lxd/lxd-container-image-inner.nix b/nixos/maintainers/scripts/lxd/lxd-container-image-inner.nix index ef00c6f86cbd..4698971de8ff 100644 --- a/nixos/maintainers/scripts/lxd/lxd-container-image-inner.nix +++ b/nixos/maintainers/scripts/lxd/lxd-container-image-inner.nix @@ -13,8 +13,23 @@ ./lxd.nix ]; - networking.useDHCP = false; - networking.interfaces.eth0.useDHCP = true; + networking = { + dhcpcd.enable = false; + useDHCP = false; + useHostResolvConf = false; + }; + + systemd.network = { + enable = true; + networks."50-eth0" = { + matchConfig.Name = "eth0"; + networkConfig = { + DHCP = "ipv4"; + IPv6AcceptRA = true; + }; + linkConfig.RequiredForOnline = "routable"; + }; + }; system.stateVersion = "@stateVersion@"; # Did you read the comment? } diff --git a/nixos/maintainers/scripts/lxd/lxd-container-image.nix b/nixos/maintainers/scripts/lxd/lxd-container-image.nix index b77f9f5aabe0..3f330952d695 100644 --- a/nixos/maintainers/scripts/lxd/lxd-container-image.nix +++ b/nixos/maintainers/scripts/lxd/lxd-container-image.nix @@ -25,7 +25,21 @@ fi ''; - # Network - networking.useDHCP = false; - networking.interfaces.eth0.useDHCP = true; + networking = { + dhcpcd.enable = false; + useDHCP = false; + useHostResolvConf = false; + }; + + systemd.network = { + enable = true; + networks."50-eth0" = { + matchConfig.Name = "eth0"; + networkConfig = { + DHCP = "ipv4"; + IPv6AcceptRA = true; + }; + linkConfig.RequiredForOnline = "routable"; + }; + }; }