[Q] LXC network config in container using veth

cmonty14

Well-Known Member
Mar 4, 2014
343
5
58
Hello!

How can I configure the network of any LXC container?

The host is providing a Linux Bridge vmbr0 and gets IP of internal network 192.168.178.0/24.
My intention is that any LXC container gets IP via DHCP in same network 192.168.178.0/24.
Modifying /etc/network/interfaces in container is not working; after reboot the settings are overwritten.

I assume there's a config file for every container defining the network settings.
Where can I find this?
And what is the recommended setting?

THX
 
Either you define network on the host (use the GUI), or inside the container. But I am not sure if
we always write the config - if so, this is a bug.
 
Unfortunately either option for network configuration fails, means inside container or on host using GUI.

Inside container, I have currently this config:
Code:
root@vm103-mariadb:~# cat /etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

But when I modify this config by adding a "simple bridge"
Code:
auto lo
iface lo inet loopback

#auto eth0
#iface eth0 inet manual

auto vmbr0
iface vmbr0 inet dhcp
        bridge_ports eth0
        bridge_fd 0
        bridge_maxwait 0
this config will be overwritten after rebooting the container like this:
Code:
auto lo
iface lo inet loopback

#auto eth0
#iface eth0 inet manualauto vmbr0

auto vmbr0
iface vmbr0 inet dhcp
        bridge_ports eth0
        bridge_fd 0
        bridge_maxwait 0
auto eth0
iface eth0 inet manual

So trying to config network using host GUI is not successful either.
This means, without defining IP address and Gateway, it's not working.
But when I try to define an IPv4 address Gateway (IPv4), I cannot confirm this without content mandatory fields "IPv6/CIDR" and "Gateway (IPv6).

Please check the attached screenshot for details.

The thing is that I don't want a static IPv4 for the container, but a dynamic DHCP instead.
And IPv6 is not wanted at all.
According to the wiki I don't use IPv6 address on the host
"Note: Make sure that no IPv6 address for your hostname is specified in /etc/hosts"
and my config is this:
Code:
root@pc3-supermicro:~$ cat /etc/hosts
127.0.0.1       localhost.localdomain localhost
192.168.100.11  pc3-supermicro.domain.lan  pc3-supermicro  pvelocalhost

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

Can you please advise?

THX
 

Attachments

  • Auswahl_077.png
    Auswahl_077.png
    33 KB · Views: 27
Hey you should insert your ipv4 address like this: 192.168.100.103/24
cu peje
Unfortunately either option for network configuration fails, means inside container or on host using GUI.

Inside container, I have currently this config:
Code:
root@vm103-mariadb:~# cat /etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

But when I modify this config by adding a "simple bridge"
Code:
auto lo
iface lo inet loopback

#auto eth0
#iface eth0 inet manual

auto vmbr0
iface vmbr0 inet dhcp
        bridge_ports eth0
        bridge_fd 0
        bridge_maxwait 0
this config will be overwritten after rebooting the container like this:
Code:
auto lo
iface lo inet loopback

#auto eth0
#iface eth0 inet manualauto vmbr0

auto vmbr0
iface vmbr0 inet dhcp
        bridge_ports eth0
        bridge_fd 0
        bridge_maxwait 0
auto eth0
iface eth0 inet manual

So trying to config network using host GUI is not successful either.
This means, without defining IP address and Gateway, it's not working.
But when I try to define an IPv4 address Gateway (IPv4), I cannot confirm this without content mandatory fields "IPv6/CIDR" and "Gateway (IPv6).

Please check the attached screenshot for details.

The thing is that I don't want a static IPv4 for the container, but a dynamic DHCP instead.
And IPv6 is not wanted at all.
According to the wiki I don't use IPv6 address on the host
"Note: Make sure that no IPv6 address for your hostname is specified in /etc/hosts"
and my config is this:
Code:
root@pc3-supermicro:~$ cat /etc/hosts
127.0.0.1       localhost.localdomain localhost
192.168.100.11  pc3-supermicro.domain.lan  pc3-supermicro  pvelocalhost

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

Can you please advise?

THX
 
OK.
This is working.

However, this solution implies that I cannot use DHCP in a LXC containter.
Can you confirm?

THX
 
If your /etc/network/interfaces file contains this:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

Your container should get an IP from DHCP. Of course this requires that a DHCP server is running on the network and that the DHCP server distributes an IP to the container.
 
If your /etc/network/interfaces file contains this:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

Your container should get an IP from DHCP. Of course this requires that a DHCP server is running on the network and that the DHCP server distributes an IP to the container.

Please check my previous posting.
Any modification in /etc/network/interfaces will be overwritten after rebooting the container.
 
Either you define network on the host (use the GUI), or inside the container. But I am not sure if
we always write the config - if so, this is a bug.

Hi!

If you recommend I would open a bug report because any modification, e.g. in /etc/hosts or /etc/network/interfaces, will be overwritten from config after restarting the container.

The question is:
If I cannot modify the config in GUI, can I at least modify the configfile directly on console?

THX
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!