Network disconnects during update


I’ve run into an annoying and rather unpredictable issue lately. I have a shared nixOS configuration for multiple hosts, and 2 of the systems will randomly disconnect from the network when I run sudo nixos-rebuild switch

The systems that have a problem have networking options that look something like:

			# Enable networking, with DHCP and a bridge device

			networking.useDHCP = false;

			# Setup a bridge to be used with libvirt
			networking.interfaces.enp42s0.useDHCP = true;
			networking.interfaces.br0.useDHCP = true;
			networking.bridges.br0.interfaces = [ "enp42s0" ];

I’m really not sure what to change to make this more reliable. The machines that don’t have this issue all use Network Manager instead, but these two need the bridge for the sake of libvirt VMs.

I suppose I could switch these to Network Manager as well, but I’m not sure if I can declarative setup the bridge if I do that?

If you run journalctl -f just before switching, does that give you any useful logs that might indicate what’s happening under the hood? Anything in networkctl status afterwards?

I did switch today, and… it didn’t happen. So, next time it does I’ll have to try these. Last time it happened I didn’t have time to try this, and just got the box up.

First point: don’t run DHCP on both the bridge and the member, they’re probably getting in eachother’s way for the same mac and lease on different interfaces (even if the same access segment). Just run it on the bridge.

That said, though, I had similar issues on a host with the same setup, even without this complication. I switched to using networkd to set the config and it’s been fine since: = {
    enable = true;
    netdevs = {
      "20-br0" = {
        netdevConfig = {
          Kind = "bridge";
          Name = "br0";
    networks = {
      "30-eno1" = {
        name = "eno1";
        bridge = [ "br0" ];
      "30-br0" = {
        name = "br0";
        DHCP = "yes";

Thanks, I’ll have to try that. I haven’t ever used networkd, but I don’t have any objection to it either.

For situations like this, it’s a little more verbose and that seems annoying.

But I have some far more complicated setups¹, and for those it’s just the only way to do what’s needed and is quite elegant when you get used to it.

1: bridges with vlan filtering, multiple ports with bridge priorities, different containers being added to different vlans on the same bridge, etc.

1 Like