Set up DHCP for LXC containers

keda

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.

Hesham Ahmed

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to set up networking for lxc containers in OpenStack?

From Dev

Set up a router with DHCP in a non DHCP network

From Dev

How to set up a DHCP server?

From Dev

How to set up a DHCP server?

From Dev

LXC containers as a sandbox environment

From Dev

LXC Containers & Bridge Connection

From Dev

USB passthrough for LXC containers

From Dev

LXD Containers and Host on DHCP

From Dev

Web Based Management For LXC Containers?

From Dev

LXC external IP configuration for containers

From Dev

LXC-Routing between containers

From Dev

Openstack LXC containers missing DNS

From Dev

Source NAT rule for LXC containers

From Dev

Access lxc container services from other lxc containers via host

From Dev

LXC containers not accessible using .lxc dns domain on Ubuntu 14.4

From Dev

How to set up a bridge between two docker containers (connection refused)

From Dev

User permissions inside and outside of LXC containers?

From Dev

How do I Backup / Move LXC containers?

From Dev

Allow loop mounting files inside LXC containers?

From Dev

User permissions inside and outside of LXC containers?

From Dev

Allow loop mounting files inside LXC containers?

From Dev

Nginx virtual hosts for multiple LXC containers

From Dev

How dangerous is it not to load `seccomp` rules for LXC containers?

From Dev

GUI inside LXC 2.0/LXD containers

From Dev

How to use lxc profile set?

From Dev

how do you set up a linux client to use ntp information provided through dhcp?

From Dev

How do I set up an Ubuntu server to be the router for two private networks on my network, and do the DHCP addressing?

From Dev

Set DHCP with manual IP

From Dev

LXC - Linux Containers - Add new network interface without restarting

Related Related

HotTag

Archive