[Nix-dev] Networking to containers

Johannes Bornhold johannes.bornhold at gmail.com
Thu Mar 23 14:17:13 CET 2017


Hi!

> On 17 Mar 2017, at 09:27, Alexander Shulyak <alexander.shulyak at solbeg.com> wrote:
> I have an a question about network interfaces for containers in Nixos.
> How I can make a network of container as a full-fledged part of a host network?
> So, I have a host network with subnet in ip-address range 10.0.0.0/23, and I want that network of container on nixos host is also be in this subnet. How I can forward this interface to the container?
> I already try to make bridge, but it drop the network on host.

I am currently fiddling around in a similar area, I think there are some options available.
If I understood you correctly, then you want your containers to work as if they are connected
directly to the host's network.

Using the "hostBridge" setting for the container should do the trick. Just make
sure that the bridge does exist on the host and also includes
the real network interface of your host.

For imperative containers there should be a flag "--bridge" to nixos-container. Also setting
HOST_BRIDGE in the container's config file on the host should do the trick,
that's in "/etc/containers/NAME.conf".


One option which I did not yet try myself might be using "MACVLANS". 
I think that's creating virtual interfaces for the container directly
on top of an existing host interface.


When I studied the things, it helped me a lot to look into the script which starts the containers,
it can be found here: https://github.com/NixOS/nixpkgs/blob/release-16.09/nixos/modules/virtualisation/containers.nix#L89


Hope the fragments are useful :)

Cheers, Johannes




More information about the nix-dev mailing list