Today, when viewing a virtual machine, you find that a network card contains multiple IP addresses:
eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> MTU theQdisc Pfifo_fast State up Qlen +Link/etherxx: 0c: in: 6b:a5:a2 BRD ff:ff:ff:ff:ff:ff inet192.168.213.132/ -Brd192.168.213.255Scope Global Dynamic eno16777736 valid_lft 1726sec preferred_lft 1726sec inet192.168.213.34/ -Brd192.168.213.255Scope Global Secondary eno16777736 valid_lft forever Preferred_lft Forever
Where 192.168.213.132 is the primary IP address, 192.168.213.34 to remove the master IP address from the IP address, execute the following command:
192.168. 213.132 Dev eno16777736
Viewing the results will reveal that the IP address is not there.
It turns out that there is a kernel parameter that controls this:
When you drop the primary IP of a subnet, all related IP will be down.
Set a kernel parameter that can be promoted from IP to primary IP when the primary IP is down:
Echo " 1 " >/proc/sys/net/ipv4/conf/all/promote_secondaries
Execute the command to remove the IP again:
192.168. 213.132 Dev eno16777736
Enter IP addr To view the results:
the + link: 0c:6b:a5:a2 brd ff:ff:ff:ff:ff:ff192.168 . 213.34/192.168. 213.255 Scope Global eno16777736 valid_lft forever Preferred_lft Forever
Upgrade from IP to primary IP, done!
This article is for Bo Master original article, without permission not reproduced. Reprint Please specify source: https://www.cnblogs.com/lijinze-tsinghua/
A network card in Linux contains multiple IPs, and the method of upgrading from IP to primary IP