Help: Network magic on boot, or systemd one time script? (docker / macvlan)

The first command of your script is creating a macvlan interface, which is what networking.macvlans does.

The declarative way to do what your script is trying to do is something like this:

{
  networking.macvlans."myNewNet-shim" = {
    mode = "bridge";
    interface = "enp3s0";
  };

  networking.interfaces."myNewNet-shim".ipv4 = {
    addresses = [{ address = "192.168.1.67"; prefixLength = 32; }];
    routes = [{ address = "192.168.1.64"; prefixLength = 30; }];
  };

}

I haven’t read the blog and I don’t know much about Docker, but I’m the maintainer of the networking.interfaces module, so I’m pretty sure what these options do. Your script is actually pretty similar to the “scripted” networking implementation (you can check for yourself: createMacvlanDevice, configureAddrs), except that it lacks the proper dependencies and the clean up part.

3 Likes