Add a secondary ip address in linux

Source: Internet
Author: User

In linux, add a secondary ip address. In addition to primary, there are two types of ip addresses: 1. ip alias (sub-interface) 2. secondary ip (secondary ip) www.2cto.com can be added to a physical network card. alias is added by ifconfig. ifconfig is displayed as a sub-interface, such as eth0: 1; secondary ip is supported by ip commands. add sub-interface: # ifconfig eth0: 1 10.10.56.33/24 up # Add to memory and take effect immediately. You can view ifconfig and ip addr sh. you can also create a corresponding sub-interface configuration file under the/etc/sysconfig/network-scripts directory: cd/etc/sysconfig/network-scripts; cp ifcfg-eth0: 0; Edit: ifcfg-eth0: 0, change the DEVICE name and ip address can be: DEVICE = eth0: 0 IPADDR = 10.10.56.33 Linux up to 255 ip alias. www.2cto.com add secondary ip: # ip a add dev eth1 172.16.18.18/24 brd 172.16.18.255 # ip a sh dev eth1 ...... inet 172.16.18.118/24 brd 172.16.18.255 scope global secondary eth1 # If the ip address of the same network segment is added, the secondary ip address is displayed. If the ip address is not the same network segment, it is primary. however, for physical NICs, except for the first configured IP address, the added IP address can be regarded as secondary. the ip ifconfig command added here is invisible. as far as I know, adding a secondary ip address to the ip address is only added to the memory. I don't know if it can be implemented in the configuration file.
 

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.