A network card in Linux contains multiple IPs, and the method of upgrading from IP to primary IP

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.