Fedora-33 :: LXC v4.x :: Static IP-Addressing

Hello Friends:

  • On the Fedora-33 LXC HOST (lxc version 4.x), there are no LXC related daemons running. It’s kept very simple (and all of this used to work).

  • LXC containers are started manually via: user@host$ sudo lxc-start --daemon --name vps20

  • In the Fedora-33 LXC GUEST, the IP-Address is specified in: /etc/sysconfig/network-scripts/ifcfg-eth0 (standard location) as follows:

DEVICE=eth0
NAME=eth0
HWADDR=22:22:22:22:22:20
IPADDR=192.168.0.200
GATEWAY=192.168.0.1
NETMASK=255.255.255.0
PREFIX=24
DNS1=8.8.8.8
DNS2=8.8.4.4
DNS3=1.1.1.1
TYPE=Ethernet
BOOTPROTO=none # I also tried 'static' here.
NM_CONTROLLED=no
ONBOOT=yes
USERCTL=no
IPV6INIT=no
DEFROUTE=yes
PROXY_METHOD=none
BROWSER_ONLY=no
IPV4_FAILURE_FATAL=no
  • dhcp, dnsmasq or whatever else are not running on the LXC Host or LXC Guest (again, kept very simple). As well, NetworkManager is not installed on the LXC Guest.

With that in mind, the LXC Guest isn’t getting the above IP-Address for eth0. Rather, its getting the following:

user@vps20$ sudo ifconfig -a
br-888b5c9d98b2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.19.0.1  netmask 255.255.0.0  broadcast 172.19.255.255
        inet6 fe80::42:7aff:fe64:4c2a  prefixlen 64  scopeid 0x20<link>
        ether 02:42:7a:64:4c:2a  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:a4:fa:09:64  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.251  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::2022:22ff:fe22:2220  prefixlen 64  scopeid 0x20<link>
        ether 22:22:22:22:22:20  txqueuelen 1000  (Ethernet)
        RX packets 2573  bytes 351788 (343.5 KiB)
        RX errors 0  dropped 15  overruns 0  frame 0
        TX packets 860  bytes 117516 (114.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

veth83c5f4d: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::c4fc:f8ff:fee8:4424  prefixlen 64  scopeid 0x20<link>
        ether c6:fc:f8:e8:44:24  txqueuelen 0  (Ethernet)
        RX packets 77  bytes 11251 (10.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 96  bytes 12966 (12.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vethb3d70e2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::20b7:9dff:fe78:608e  prefixlen 64  scopeid 0x20<link>
        ether 22:b7:9d:78:60:8e  txqueuelen 0  (Ethernet)
        RX packets 71  bytes 10800 (10.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 102  bytes 13417 (13.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

PS: Yes, docker(1) is running inside the LXC Guest container. This is for a separate purpose.

How do I get LXC to assign the Static IP-Address specified above? Below is it’s ./config file.

# ./config
#
lxc.include = /usr/share/lxc/config/common.conf
lxc.include = /usr/share/lxc/config/userns.conf
lxc.include = /usr/share/lxc/config/nesting.conf

lxc.uts.name = vps20
lxc.rootfs.path = dir:/var/lib/lxc/vps20/rootfs
lxc.mount.fstab = /var/lib/lxc/vps20/fstab
lxc.arch = x86_64
lxc.net.0.type = veth
lxc.net.0.link = lxcbr0
lxc.net.0.name = eth0
lxc.net.0.flags = up
lxc.net.0.ipv4.gateway = 192.168.0.1
lxc.net.0.ipv4.address = 192.168.0.200/24
lxc.net.0.hwaddr = 22:22:22:22:22:20

lxc.cgroup.cpuset.cpus = 0,1,2,3,4,5,6,7,8,9,10,11
lxc.cgroup.cpu.shares = 100

lxc.mount.entry = /dev/kmsg dev/kmsg none defaults,bind,create=file
linux.kernel_modules  = ip_tables,ip6_tables,netlink_diag,nf_nat,overlay

lxc.mount.auto = proc:rw sys:rw cgroup:rw:force
lxc.init.cmd = /sbin/init systemd.unified_cgroup_hierarchy=1
security.nesting = true
security.privileged = true
lxc.cap.drop =
lxc.cgroup.devices.allow =
lxc.cgroup.devices.deny =
lxc.cgroup2.devices.allow =
lxc.cgroup2.devices.deny =

Bump. :slight_smile:

No replies?

Well, something is clearly doing some kind of auto-configuration in there, that or you have some other config setting that address.

So you’d want to first grep for that address in the container to see if it’s coming from some config. If not, then run tcpdump against lxcbr0 and see what happens when the container starts.