How to configure multiple IP addresses for one Nic In Centos 7
Sometimes at work, we may encounter a situation where one Nic is configured with multiple ip addresses, especially for linux servers.
So I sorted out the configuration process as follows, hoping to help my friends who encountered the same problem. Here we take Centos 7 under vmwarevm as an example. The specific configuration process is as follows:
[Method 1: add multiple IP addresses through the NIC configuration file]
1. Edit the eno16777736 Nic configuration file/etc/sysconfig/network-scripts/ifcfg-eno16777736 and add
TYPE = EthernetBOOTPROTO = noneNAME = eno167736device = Signature = yesIPADDR0 = Signature = 27GATEWAY0 = 10.91.137.65 ##################### IPADDR1 = 192.168.100.2 PREFIX1 = 24 // if only one ip address uses the IPADDR and PREFIX options, numbers cannot be added to the end.
2. Run the systemctl restart network. service command to restart the network service and view the NIC information, as shown in
========================================================== ==============================
[Method 2: add the nic ip alias]
In Linux, We can configure multiple IP addresses on a physical network card to implement functions similar to sub-interfaces, which we call an IP alias.
We can use the IP alias to configure multiple IP addresses on a physical network card. The implementation process is as follows:
1, such as eno16777736 Nic configuration file ifcfg-eno16777736 content is as follows, here we also set only one IP
TYPE=EthernetBOOTPROTO=noneNAME=eno16777736DEVICE=eno16777736ONBOOT=yesIPADDR=10.91.137.66NETMASK=255.255.255.0GATEWAY=10.91.137.65
2, next we create a NIC alias file/etc/sysconfig/network-scripts/ifcfg-eno16777736: 0 file, add the following content
TYPE = EthernetBOOTPROTO = noneNAME = eno16777736: 0 DEVICE = eno16777736: 0 ONBOOT = yesIPADDR = 192.168.100.3NETMASK = 255.255.255.0 # PREFIX = 24
3. Run the systemctl restart network. service command to restart the network service and view the NIC information. The result is as follows:
[root@5201351 ~]# ip addr show eno167777362: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:5b:b2:08 brd ff:ff:ff:ff:ff:ff inet 10.91.137.66/27 brd 10.91.137.95 scope global eno16777736 valid_lft forever preferred_lft forever inet 192.168.100.3/24 brd 192.168.100.255 scope global eno16777736:0 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe5b:b208/64 scope link valid_lft forever preferred_lft forever
Respect others' labor results reprinted please be sure to indicate the source: http://www.cnblogs.com/5201351/p/4937953.html