I'm having a difficult time configuring the IP address of an interface in a Fedora 32 in a LXD container.
The configuration for eth0 in /etc/sysconfig/network-scripts/: # cat ifcfg-eth0 TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=none DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=no IPV6_DEFROUTE=no IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=eth0 DEVICE=eth0 ONBOOT=yes IPADDR=192.168.20.43 PREFIX=24 GATEWAY=192.168.20.1 IPV6_DISABLED=yes DNS1=192.168.20.1 DNS2=75.75.75.75 DNS3=8.8.8.8 HWADDR=00:16:3e:d1:ea:86
When I start the container, eth0 gets two IP addresses. One is the IP specified in the ifcfg-eth0 file. The other is a DHCP address. I'm assuming that NetworkManager is getting the DHCP address.
I tried adding NMCONTROLLED=no to the ifcfg, but I get the same double IP assignment.
I've tried removing the ifcfg-eth0 file and configuring the interface using nmcli as described here: https://linuxconfig.org/how-to-configure-static-ip-address-on-fedora-31
That doesn't work. When the container restarts, a new eth0 is created with a different UUID.
Any suggestions would be appreciated.
On 7/8/20 10:35 AM, Michael Eager wrote:
I'm having a difficult time configuring the IP address of an interface in a Fedora 32 in a LXD container.
The configuration for eth0 in /etc/sysconfig/network-scripts/: # cat ifcfg-eth0 TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=none DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=no IPV6_DEFROUTE=no IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=eth0 DEVICE=eth0 ONBOOT=yes IPADDR=192.168.20.43 PREFIX=24 GATEWAY=192.168.20.1 IPV6_DISABLED=yes DNS1=192.168.20.1 DNS2=75.75.75.75 DNS3=8.8.8.8 HWADDR=00:16:3e:d1:ea:86
When I start the container, eth0 gets two IP addresses. One is the IP specified in the ifcfg-eth0 file. The other is a DHCP address. I'm assuming that NetworkManager is getting the DHCP address.
I tried adding NMCONTROLLED=no to the ifcfg, but I get the same double IP assignment.
I've tried removing the ifcfg-eth0 file and configuring the interface using nmcli as described here: https://linuxconfig.org/how-to-configure-static-ip-address-on-fedora-31
That doesn't work. When the container restarts, a new eth0 is created with a different UUID.
Any suggestions would be appreciated.
Hello Michael Eager,
I'm just a user but I tried this and it works. I'm assuming a basic setup where the container is attached to a bridge.
Instead of defining eth0 in the container do it in a profile..
devices: eth0: type: nic name: eth0 hwaddr: 00:16:3e:01:02:03 ipv4.address: 4.3.2.100 /* container's PREFIX is same as bridge */ nictype: bridged /* bridge net: 4.3.2.0 */ parent: LXD /* bridge ip: 4.3.2.1 */
The container's ip will be assigned via host dhcp but will use the mac/ip specified in the profile. You can use the container's sysctl.conf to disable ipv6. DNS could be specified *within* the container's /etc/resolv.conf. You could also insert it using the profile's *runcmd* feature.
As to UUID of the nic: I don't remember seeing the ability to assign UUIDs to devices using lxc but is probably doable from the profile. Since the device's UUID would be internal to your container, does it need one?
Hope these ideas are useful, Mike Wright
On Wed, Jul 8, 2020 at 7:35 PM Michael Eager eager@eagercon.com wrote:
I'm having a difficult time configuring the IP address of an interface in a Fedora 32 in a LXD container.
The configuration for eth0 in /etc/sysconfig/network-scripts/: # cat ifcfg-eth0 TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=none DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=no IPV6_DEFROUTE=no IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=eth0 DEVICE=eth0 ONBOOT=yes IPADDR=192.168.20.43 PREFIX=24 GATEWAY=192.168.20.1 IPV6_DISABLED=yes DNS1=192.168.20.1 DNS2=75.75.75.75 DNS3=8.8.8.8 HWADDR=00:16:3e:d1:ea:86
When I start the container, eth0 gets two IP addresses. One is the IP specified in the ifcfg-eth0 file. The other is a DHCP address. I'm assuming that NetworkManager is getting the DHCP address.
I tried adding NMCONTROLLED=no to the ifcfg, but I get the same double IP assignment.
I've tried removing the ifcfg-eth0 file and configuring the interface using nmcli as described here:
https://linuxconfig.org/how-to-configure-static-ip-address-on-fedora-31
That doesn't work. When the container restarts, a new eth0 is created with a different UUID.
I use lxc and not lxd, but I suspect that they are conceptually similar.
An lxc container's ip configuration's set by lxc's "external" configuration, and not by the container's "internal" configuration.
$ cat /etc/lxc/default.conf lxc.net.0.flags = up lxc.net.0.hwaddr = 00:16:3e:xx:xx:xx lxc.net.0.link = lxcbr0 lxc.net.0.type = veth lxc.net.0.veth.mode = bridge
$ cat /lxc/alpine/config ... lxc.net.0.ipv4.address = 192.168.124.241/24 lxc.net.0.ipv4.gateway = 192.168.124.1 lxc.net.0.name = eth0 ...
On 7/8/20 10:35 AM, Michael Eager wrote:
I'm having a difficult time configuring the IP address of an interface in a Fedora 32 in a LXD container.
The configuration for eth0 in /etc/sysconfig/network-scripts/: # cat ifcfg-eth0 TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=none DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=no IPV6_DEFROUTE=no IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=eth0 DEVICE=eth0 ONBOOT=yes IPADDR=192.168.20.43 PREFIX=24 GATEWAY=192.168.20.1 IPV6_DISABLED=yes DNS1=192.168.20.1 DNS2=75.75.75.75 DNS3=8.8.8.8 HWADDR=00:16:3e:d1:ea:86
When I start the container, eth0 gets two IP addresses. One is the IP specified in the ifcfg-eth0 file. The other is a DHCP address. I'm assuming that NetworkManager is getting the DHCP address.
I found the culprit that is getting a DHCP IP address: systemd-networkd.
There are two competing processes managing networks: NetworkManager and Systemd. Feh!
I removed the ifcfg in /etc/sysconfig/network-scripts/ and put the following in /etc/systemd/network/:
# cat eth0.network [Match] Name=eth0
[Network] LinkLocalAddressing=ipv4 Address=192.168.20.43/24 Gateway=192.168.20.1 DNS=192.168.20.1 DNS=75.75.75.75 DNS=8.8.8.8