Configure and get up second network interface

Hello. I posted this in matermost channel but no one anwered, so I’m posting here.

I’m trying to configure a second interface in a Rocky Linux 9 LXC container (LXD/Incus). I’ve defined the second interface as macvlan in the container profile, and I want it to get an ip address from my router. I did this before in an Ubuntu container just configuring my second interface in netplan conf file, but I don’t know how to do it with NetworkManager.

[root@r1 ~]# nmcli dev
DEVICE  TYPE      STATE                   CONNECTION
eth1    ethernet  connected               Wired connection 1
lo      loopback  connected (externally)  lo
eth0    macvlan   unmanaged               --
[root@r1 ~]# nmcli con
NAME                UUID                                  TYPE      DEVICE
Wired connection 1  c659e992-2e24-3a83-94c0-b5ac07fb0185  ethernet  eth1
lo                  328f7a75-52de-4883-a35e-50eef576e153  loopback  lo
System eth0         5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03  ethernet  --

tried

[root@r1 ~]# nmcli con modify "System eth0" connection.interface-name eth0
[root@r1 ~]# nmcli con up "System eth0"
Error: Connection activation failed: No suitable device found for this connection (device eth1 not available because profile is not compatible with device (mismatching interface name)).

How to get the second interface (eth0) up?

I don’t have an answer, so I did search with that and first hit was: NetworkManager cannot manage macvlan devices inside container (#785) · Issues · NetworkManager / NetworkManager · GitLab
Note that that is not strictly about el9.

Thank you for your find. The last comment is 11 months old so I suppose it is affecting to el9 too. :frowning:

So I workarounded it. Good bye NetworkManager, hello networkd and netplan. Posting this just for someone having same problem until they fix NetworkManager. In my container I did:

Install EPEL repository

sudo dnf upgrade --refresh
sudo dnf install 'dnf-command(config-manager)'
sudo dnf config-manager --set-enabled crb

then

sudo dnf install \
    https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm \
    https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-9.noarch.rpm

Install packages for networkd and netplan

sudo dnf makecache --refresh
sudo dnf install systemd-networkd systemd-resolved netplan

set up systemd-resolved

sudo systemctl enable systemd-resolved --now
sudo mv /etc/resolv.conf /etc/resolv.conf.sos
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

configure netplan
nano /etc/netplan/10-lxc.yaml
I’ve used this for my two interfaces, so both get ip from dhcp servers, the bridged from Incus internal bridge and the macvlan from my router

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: true
      dhcp-identifier: mac
    eth1:
      dhcp4: true
      dhcp-identifier: mac

then

sudo netplan apply
sudo systemctl enable systemd-networkd

and finally

systemctl disable NetworkManager && sudo reboot

It is working fine now.

1 Like