I have been experimenting with NixOS declarative containers and have some questions.
Goal: I want each container to appear on the local network with its own static IP address, and be accessible to every other container, as well as the host machine.
Additional information: The host interface is enp3s0, as stated in the above configuration.
Current state: Almost there. Each container is gets its own static ip address and is accessible on the network, as well as accessible from every other container. The only missing piece is that the host cannot access each container.
How should I modify my configuration.nix such that the host can reach each container?
If you want an example of using macvlan one can be found in the nixos tests nixpkgs/containers-macvlans.nix at 62f746b630d5189b2eedc19688ddcfb8021c1c71 · NixOS/nixpkgs · GitHub and it shouldn’t be too hard to extrapolate how it might apply to your own setup. Feel free to pester me in Matrix if you need some help hacking on these containers, and we can ultimately post a macvlan solution in this thread once we’ve figured it out.
I tried to do something like this in the past, based on the macvlans example in the nixos tests. IIRC, it appeared to work, but then after some period of time the host mysteriously disappeared off the network and only the container could be contacted.
Keen to try out the br0 config when I get a chance! Is br0 limited to ethernet (as opposed to wireless) interfaces the way I believe macvlan is? One of the reasons I originally gave up was that I could only test them on the actual server with a wired connection, rather than messing about with containers on my (wireless) laptop then copying the config once I’d got them working. Having the server mysteriously disappear off the network was frustrating, given that it was only easily accessible via the network.