Method 1: A small number of IPs are manually bound:
(here to bind IP to eth0 for example, the other network adapter words to modify the corresponding file name can be)
1. Copy the Ifcfg-eth0 network adapter profile and rename it to ifcfg-eth0:0
[[email protected]/]# cd/etc/sysconfig/network-cp ifcfg-eth0 ifcfg-eth0:0
2. Edit the ifcfg-eth0:0 file
[Email protected]/]# Vim/etc/sysconfig/network-scripts/ifcfg-eth0:0DEVICE= "Eth0:0″// change here to eth0:0 with file namebootproto= "Static"// protocol is static, with none can alsoHwaddr= "xx: 0C: in: 6F: +: A7″// MAC addressonboot= "Yes"// enable this network adapter on bootIpaddr=192.168.1.3 // the newly bound IPnetmask=255.255.255.0 // Subnet Maskgateway=192.168.1.1 // Gateway
3. Start the network card:
[[email protected]/]# ifup eth0:0
Note: Someone in this step like to restart the network with service network restart, in fact, this is not necessary, just need to enable this network card can be
Then try the ping again, if you can ping the words, you can.
Method 2: Automatically bind an IP segment or multiple IP segments:
(also here to eth0 for example, other network card words to modify the corresponding file name can be)
1. Create a new Ifcfg-eth0-range0 file:
(Note that the file name here does not change the location of the range or the wrong word, otherwise the binding IP will not take effect, if you have a few IP to bind to the eth0, you can create new Ifcfg-eth0-range1, Ifcfg-eth0-range2 and other files, Note, however, that the Clonenum_start values defined in each range file do not overlap, otherwise there will be a problem. )
[Email protected]/]#/etc/sysconfig/network-scripts/ifcfg-eth0-range0# write to the following device=eth0//network card name of the bound IP segmentOnboot=yes//enable this network adapter on bootBootproto=static//protocol is staticipaddr_start=192.168.0.101 //Start IP of the network segmentIpaddr_end=192.168.0.120 //cutoff IP for network segmentnetmask=255.255.255.255 //Subnet Maskclonenum_start=0 //This number is the beginning of the network card alias, for example, 3 here refers to eth0:0, and will be Ipaddr_start set IP192.168.0.101 bound to eth0:0, and so onNo_aliasrouting=yes//The function of this parameter is that the packet always passes in and out through the eth0, does not walk the network card alias (such as eth0:0), sets this parameter to speed up the route response speed, therefore strongly recommends the configuration.
2. Restart the network after:
[Email protected]/]# service network restart
Test again, you can ping is done.
CentOS one NIC to set multiple IPs