eth0:1 aliases in NM, manual setup
Íñigo Huguet
ihuguet at redhat.com
Mon Jul 22 08:16:50 UTC 2024
Hi Martin.
On Thu, Jul 4, 2024 at 1:19 PM Martin Vogt <mvogt1 at gmail.com> wrote:
>
>
> Hello,
>
> I have to migrate a server IP to a new NM managed server, which I setup.
>
> The new server has the primary IP cups6 192.168.48.46/24 (ens224) and dhcp on boot.
> I like to add a manual IP 192.168.48.16 like in the old setup, on cups5:
>
> ens224: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
> inet 192.168.48.20 netmask 255.255.255.0 broadcast 192.168.48.255
> ens224:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
> inet 192.168.48.16 netmask 255.255.255.0 broadcast 192.168.48.255
>
> ifcfg-ens224:1
> # cups ontop of cups5
> DEVICE="ens224:1"
> BOOTPROTO="static"
> ONBOOT="manual"
> IPADDR="192.168.48.16"
> NETMASK="255.255.255.0"
>
> When doing it with NM:
>
> nmcli connection modify ens224 +ipv4.addresses 192.168.48.16/24 ipv4.method manual
> - it reorders the interfaces, ens224:1/192.168.48.16 becomes primary and
> - 192.168.48.46/24 secondary
> - both are started auto or manually
>
> But it should be:
>
> primary: 192.168.48.46/24 with dhcp onboot
> second: 192.168.48.16 manual / static
Try `nmcli connection modify ens224 ipv4.addresses 192.168.48.16/24
ipv4.method auto`. This is the way to have DHCP enabled + an
additional static address. Not sure which one will be the primary, I
think it'll be the DHCP obtained one. Please try and tell us.
>
> Currently I'm doing (without NM):
>
> ip addr add 192.168.48.16/24 dev ens224 label ens224:1
> ip addr del 192.168.48.16/24 dev ens224 label ens224:1
>
> Another approach was, adding a new interface:
>
> > nmcli c add ifname ens224 type ethernet con-name ens224_1
> Connection 'ens224_1'successfully added.
> > nmcli connection modify ens224_1 +ipv4.addresses 192.168.48.16/24 ipv4.method manual
> > nmcli con up ens224_1
> Connection successfully activated
>
> But this removes the existing ens224 interface and ens224_1 becomes the only one.
Here you are mixing the concepts of interface and connection.
Interface is the device, you can see them with `nmcli device` or `ip
link`. Connection is a NetworkManager only concept that contains the
configuration to apply to a device.
With those commands you are creating a new CONNECTION (in other words,
a new configuration profile for the interface) called ens224_1 and
applying it to the INTERFACE ens224. What happens then is that the
connection that was active on the interface is brought down and the
new one is applied.
Connections can have the same name than interfaces, but if you get
confused with that, better choose different names for the connections
(i.e. ens224_con).
Regards.
--
Íñigo Huguet
More information about the Networkmanager
mailing list