My motherboard has two ethernet ports, controlled by two different drivers (
igb). One of these I use, the other is only used by a VM guest.
However, NixOS appears to be trying to use both, which creates delays.
ip addr shows a DHCP address assigned to both, and
btop shows network traffic on both. I’m not sure how it chooses which one to use, but it looks random. If I bring down one of the nics (
sudo ifconfig enp5s0 down), internet delays go away, everything uses the one enabled nic, as expected.
Since I only want a VM guest to use the second (
igb) nic, I tried added the
igb driver to
boot.blacklistedKernelModules. However, that apparently prevents the VM from accessing it as well (
virt-manager complains that the device doesn’t exist, when trying to start the VM).
Is there a middle ground? Either a way to allow a VM access to a blacklisted device, or a way to tell NixOS not to use a particular nic?
The simplest solution would be to unplug the port you don’t want to use, which should cause it to have
NO_CARRIER and should never get any sort of DHCP address (or any traffic at all).
Assuming that’s not an option, then there’s a couple of different options you can do. You can either disable DHCP using
networking.interfaces.<name>.useDHCP = false, or disable the interface entirely by using
systemd.network.netdevs.<name>.enable = false.
“It’s complicated”, alas.
There are several different things that might be configuring the network (enabling DHCP). You’ll need to find, and disable, all of them. Primary candidates include:
- NixOS system network configuration (
networking…useDHCP) as above
- NetworkManager, enabled via your desktop environment (e.g. Gnome)
Others are also possible, but are less likely - they typically need you to have done something to enable them, like the
systemd.network.* attrs for example.
For system (aka scripted) networking, there’s:
- a global
- as well as per-interface
These need to be set to
false. The defaults have changed a few times, but check the installer-generated
hardware-configuration.nix on a recent install and you’ll see they may be set there. Even if they are, it’s maybe best to explicitly override them in
For NetworkManager, there are a number of options. You can use the imperative GUI settings on the desktop, or you can use declarative config as well. Probably the best is to set
networking.networkmanager.unmanaged to list the interface needed.
If you have any more / other things involved, similar actions are needed there.
Finally, depending on your VM-hosting solution, once you’ve removed this you might need to just set the interface “up” but otherwise unconfigured, so that the vm can use the interface.
Thank you for the replies! It’ll take some time to be sure, but it looks like
networking.interfaces.<name>.useDHCP = false did the trick! I don’t use NetworkManager or anything other than DHCP, so I figured my options were limited.