Incoming traffic to nixos-container

Dear Nix users,

I want to declare nixos-containers and I would like to expose them to
the local network as if they were “normal” machines. The services
should be reachable from other machines by separate IP
addresses. Ideally, they would be configured through DHCP.

I’m a bit stuck trying multiple settings from man configuration.nix. The closest is this:

containers.fileserver = {
  config = …
  hostAddress = "";
  localAddress = "";

That creates a virtual interface on the host with IP This ip is in my network (currently I
can ping this address from other machines. But it seems that incoming
traffic is not routed to the container. Do I need to declare each port
forward or can I say “all traffic from this interface to the
container, please”? It would also be nice, if the DHCP would configure
the hostAddress, but not so important….

Is this possible? I’m sorry if I miss something obvious; As you see, I
really lack some understanding of this container networking/routing

Any help is much appreciated! Thanks

1 Like

Or you can setup OpenVPN in containers. This worked for me

Thank you so much! It works perfectly now. I was so close… I used the
macvlans setting first, but it didn’t occur to me, that I simply
have to declare the network interface in the container config…. I was
expecting too much magic….