In this talk Franz Pletz is talking about dynamic IP addressing for NixOS containers. The containers will be available via their name on the host system. I can’t find any further documentation on this, has anybody achieved this or pointers to documentation?
use <name>.containers
to access a container by name instead of ip address
3 Likes
Thank you for the reply, that is part of the solution I’m looking for. I’m now trying to assign ip addresses to the containers (with DHCP) but I can’t figure out how to do that. I’ve set up a bridge interface:
{
networking = {
useNetworkd = true;
firewall = { enable = true; };
};
systemd.network = {
enable = true;
netdevs = {
"20-br0" = {
netdevConfig = {
Kind = "bridge";
Name = "br0";
};
};
};
networks = {
"10-wan" = {
matchConfig.Name = "enp1s0";
networkConfig = {
DHCP = "ipv4";
IPv6AcceptRA = true;
Bridge = "br0";
};
linkConfig.RequiredForOnline = "routable";
};
"40-br0" = {
matchConfig.Name = "br0";
networkConfig = { DHCPServer = true; };
dhcpServerConfig = { ServerAddress = "172.16.0.1/12"; };
linkConfig = { RequiredForOnline = "routable"; };
};
# "40-vb" = {
# matchConfig.Name = "vb-*";
# networkConfig = {
# DHCP = "ipv4";
# };
# };
};
};
}
I then get a bridge device on my machine:
2: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether c6:88:8f:2e:bd:95 brd ff:ff:ff:ff:ff:ff
inet 172.16.0.1/12 brd 172.31.255.255 scope global br0
valid_lft forever preferred_lft forever
inet6 fe80::c488:8fff:fe2e:bd95/64 scope link proto kernel_ll
valid_lft forever preferred_lft forever
Now I have want to have the DHCP server assign IP addresses to my containers. I tried the 40-vb
part. But when I activate that, the br0
interface loses its IP address? I also tried to enable DHCP in the container using networking.useDHCP = lib.mkForce true;
and again br0
loses its IP address.