Hi All,
I use virtual IP from time to time on CentOS 7. just take something like eth0 and make eth0:1 put in there the IP and subnet and bring up the new IP and it works.
How do I do that with NetworkManager on the command line (assuming all static IP information) I do something like this from nmcli to set the static address: nmcli connection modify eth0 ipv4.method manual ipv6.method ignore autoconnect yes ipv4.addr 192.168.1.8/24 gw4 192.168.1.1 ipv4.dns 8.8.8.8
How then do I add a virtual IP?
Thanks
Jerry
On Mon, Jan 18, 2021 at 2:56 PM Jerry Geis jerry.geis@gmail.com wrote:
Hi All,
I use virtual IP from time to time on CentOS 7. just take something like eth0 and make eth0:1 put in there the IP and subnet and bring up the new IP and it works.
How do I do that with NetworkManager on the command line (assuming all static IP information) I do something like this from nmcli to set the static address: nmcli connection modify eth0 ipv4.method manual ipv6.method ignore autoconnect yes ipv4.addr 192.168.1.8/24 gw4 192.168.1.1 ipv4.dns 8.8.8.8
How then do I add a virtual IP?
Thanks
Jerry
With nmcli you should use: nmcli con mod eth0 +ipv4.addresses 192.168.1.X/24
This would modify your existing ifcfg-eth0 adding the lines:
IPADDR1=192.168.1.X PREFIX1=24
To have the new setting applied and your new ip alias up and running you can then use
nmcli dev reapply eth0 (supposing the device name bound to the connection is eth0)
You can also manually modify the file adding the two lines above and then run: nmcli con reload nmcli dev reapply eth0
I think you should not lose your connection, but always test on a non production machine with the same os version... just for safety HIH, Gianluca
On Mon, Jan 18, 2021 at 2:56 PM Jerry Geis jerry.geis@gmail.com wrote:
Hi All,
I use virtual IP from time to time on CentOS 7. just take something like eth0 and make eth0:1 put in there the IP and subnet and bring up the new IP and it works.
How do I do that with NetworkManager on the command line (assuming all static IP information) I do something like this from nmcli to set the static address: nmcli connection modify eth0 ipv4.method manual ipv6.method ignore autoconnect yes ipv4.addr 192.168.1.8/24 gw4 192.168.1.1 ipv4.dns 8.8.8.8
How then do I add a virtual IP?
Thanks
Jerry
With nmcli you should use: nmcli con mod eth0 +ipv4.addresses 192.168.1.X/24
This would modify your existing ifcfg-eth0 adding the lines:
IPADDR1=192.168.1.X PREFIX1=24
To have the new setting applied and your new ip alias up and running you can then use
nmcli dev reapply eth0 (supposing the device name bound to the connection is eth0)
You can also manually modify the file adding the two lines above and then run: nmcli con reload nmcli dev reapply eth0
I think you should not lose your connection, but always test on a non production machine with the same os version... just for safety HIH, Gianluca
Hi Gianluca,
Am I right that what you describe doesn't add an alias device like eth0:1 but adds the additional IP address to the eth0 device?
Apart from that, when running with NetworkManager, can one still add a temporary eth0:1 alias (with ifconfig/ip), use it and remove it again, or does NM somehow prevent this?
Regards, Simon
On Mon, Jan 18, 2021 at 6:51 PM Simon Matter simon.matter@invoca.ch wrote:
Hi Gianluca,
Am I right that what you describe doesn't add an alias device like eth0:1 but adds the additional IP address to the eth0 device?
Yes, in fact after adding it I see this kind of thing (with my ip test addressing on eth1):
# ip a . . . 3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 52:54:00:61:73:d4 brd ff:ff:ff:ff:ff:ff inet 192.168.124.102/24 brd 192.168.124.255 scope global noprefixroute eth1 valid_lft forever preferred_lft forever inet 192.168.124.152/24 brd 192.168.124.255 scope global secondary noprefixroute eth1 valid_lft forever preferred_lft forever
Apart from that, when running with NetworkManager, can one still add a temporary eth0:1 alias (with ifconfig/ip), use it and remove it again, or does NM somehow prevent this?
Regards, Simon
I think it is not managed by NM. I didn't find anything in its documentation Probably to have it configured you need to setup the desired interfaces/connections using NM_CONTROLLED=no in its configuration and use the classic network service Also because the eth0:1 ip aliasing way is deprecated https://www.kernel.org/doc/html/latest/networking/alias.html and perhaps NM uses only iproute2...
Gianluca
On Mon, 18 Jan 2021 at 12:51, Simon Matter simon.matter@invoca.ch wrote:
On Mon, Jan 18, 2021 at 2:56 PM Jerry Geis jerry.geis@gmail.com wrote:
Hi All,
I use virtual IP from time to time on CentOS 7. just take something like eth0 and make eth0:1 put in there the IP and subnet and bring up the new IP and it works.
How do I do that with NetworkManager on the command line (assuming all static IP information) I do something like this from nmcli to set the static address: nmcli connection modify eth0 ipv4.method manual ipv6.method ignore autoconnect yes ipv4.addr 192.168.1.8/24 gw4 192.168.1.1 ipv4.dns 8.8.8.8
How then do I add a virtual IP?
Thanks
Jerry
With nmcli you should use: nmcli con mod eth0 +ipv4.addresses 192.168.1.X/24
This would modify your existing ifcfg-eth0 adding the lines:
IPADDR1=192.168.1.X PREFIX1=24
To have the new setting applied and your new ip alias up and running you can then use
nmcli dev reapply eth0 (supposing the device name bound to the connection is eth0)
You can also manually modify the file adding the two lines above and then run: nmcli con reload nmcli dev reapply eth0
I think you should not lose your connection, but always test on a non production machine with the same os version... just for safety HIH, Gianluca
Hi Gianluca,
Am I right that what you describe doesn't add an alias device like eth0:1 but adds the additional IP address to the eth0 device?
Apart from that, when running with NetworkManager, can one still add a temporary eth0:1 alias (with ifconfig/ip), use it and remove it again, or does NM somehow prevent this?
There are several issues which get in the way, but the major one is with the iproute command replacing net-tools (versus NetworkManager)
https://unix.stackexchange.com/questions/192908/how-do-you-create-an-ip-alia... https://unix.stackexchange.com/questions/87829/difference-between-virtual-in...
[The major issues I run into is that ethX is considered a kernel only interface and may not always point to the same interface depending on the day of the week.. that gets added onto how iproute wants to do 'aliases' versus proper port configs and then NetworkManager sits on top and get the blame :)]
Regards, Simon
CentOS mailing list CentOS@centos.org https://lists.centos.org/mailman/listinfo/centos