nmcli and secondary ip address on demand.
by Pigi_102 from LinuxQuestions.org on (#5HH3Q)
Hi all,
I'm struggling to find a way to get two ip addresses on a single interface, but the secondary one only when I issue a command.
I explain better: I have a machine with a single interface ( eth0 ) configured for, say, 192.168.1.15/24
In the old days I usually use to create a virtual interface on it, say
ifconfig eth0:1 inet 192.168.1.30/24 and after that I could do the ifconfig eth0:1 up of ifconfig eth0:1 down whenever I would.
I could easly do the same thing with /etc/sysconfig/network-scripts/ifcfg-eth0 an ifcfg-eth0:1 and then using ifup and ifdown start or stop the interface ( eventually forcing some state with ONBOOT or ONPARENT stuffs in cfg files ).
Same goes by using ip addr commands. A couple of line in a script and you're done.
Nowadays it seems that I can't get the same thing using nmcli ( or the like ) as I can have as many "secondary" ip addresses, but I can't find a way to activate them "on demand".
if I reboot my machine, configured with a secondary ip address from nmcli/nmtui, this second ip comes up at boot whatever I do, if the primary goes up.
So my question is: is there some way to get the "old" behavior using NetworkManager stuff or I do need to disable it and goes the "old" way ?
Thanks in advance.
Pierluigi


I'm struggling to find a way to get two ip addresses on a single interface, but the secondary one only when I issue a command.
I explain better: I have a machine with a single interface ( eth0 ) configured for, say, 192.168.1.15/24
In the old days I usually use to create a virtual interface on it, say
ifconfig eth0:1 inet 192.168.1.30/24 and after that I could do the ifconfig eth0:1 up of ifconfig eth0:1 down whenever I would.
I could easly do the same thing with /etc/sysconfig/network-scripts/ifcfg-eth0 an ifcfg-eth0:1 and then using ifup and ifdown start or stop the interface ( eventually forcing some state with ONBOOT or ONPARENT stuffs in cfg files ).
Same goes by using ip addr commands. A couple of line in a script and you're done.
Nowadays it seems that I can't get the same thing using nmcli ( or the like ) as I can have as many "secondary" ip addresses, but I can't find a way to activate them "on demand".
if I reboot my machine, configured with a secondary ip address from nmcli/nmtui, this second ip comes up at boot whatever I do, if the primary goes up.
So my question is: is there some way to get the "old" behavior using NetworkManager stuff or I do need to disable it and goes the "old" way ?
Thanks in advance.
Pierluigi