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 =                                                              
lxc.network.ipv4.gateway =

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.

2 Answers 2


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

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.

  • This is a very heavyweight solution for a LXC container even 10 years ago. Using busybox udhcpc would make more sense.
    – CR.
    Nov 4 at 3:35
cat <<\EOF >> /etc/netctl/eth

I thought this would be a better way of creating the file.

  • 1
    Now that I've edited this, I see it's not really a full answer in context. The question asks about setting up DHCP for a container and the other answer covers that. It looks like this is just another option for part of the answer, and I don't see any real improvement over the other. Why are you appending to the file? Why quote the EOF marker?
    – Jeff Schaller
    Dec 15, 2021 at 1:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .