1

I have several lxc containers that need network access. At the moment I am manually allocating them IP addresses in the relevant config file as so:

lxc.network.type = veth
lxc.network.flags = up
lxc.network.name = eth0
lxc.network.link = br0 
lxc.network.ipv4 = 192.168.1.6/24                                                              
lxc.network.ipv4.gateway = 192.168.1.1

This works but does not scale and can conflict with my routers DHCP allocation. I try to use my router dhcp by leaving out the lxc.network.ipv4 lines (as described online elsewhere), and the container starts but dhcpcd reports no carrier. lxc-ls --fancy also does not show my container has an IP address. The bride is up and lxc.network.link set in the config file.

How can I use DHCP with my containers? Is it possible to use my routers DHCP, or do I need to run a server on my host? Some of my containers do need to be accessible from the outside, where as some only need to communicate to other containers/host.

I'm running arch linux, most of the help online seems ubuntu specific.

0

Make sure netctl and dhcpcd is installed inside the container (pacman -Q netctl dhcpcd) then run the following in the container:

cat > /etc/netctl/eth0
Connection=ethernet
IP=dhcp
Interface=eth0

Press CTRL-D to write the file. Then enable the profile by running:

netctl enable eth0

Finally restart the container and you should have a DHCP assigned IP address.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.