Server: add IP to network card in batch under Centos system
Server: add IP to network card in batch under Centos system
Add IP to the network card one by one under the Centos system
Create similar ifcfg-eth0:x files under / etc/sysconfig/network-scripts/, for example:
DEVICE=eth0:0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.1.100
NETMASK=255.255.255.0
NETWORK=192.168.1.1
BROADCAST=192.168.0.255
TYPE=Ethernet
Batch method can be used if it is a large number of continuous IP.
1. Establish / etc/sysconfig/network-scripts/ifcfg-eth0-range0
two。 Add the following to ifcfg-eth0-range0:
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR_START=192.168.1.100
IPADDR_END=192.168.1.200
CLONENUM_START=0
GATEWAY= Gateway address
NETMASK= subnet mask
NO_ALIASROUTING=yes
The above content will add the IP range segment from IPADDR_START (192.168.1.100) to IPADDR_END (192.168.1.200). The value of CLONENUM_START is the network card of the previous IP alias. You can view the number after the last eth0: by ifconfig. The above example is the corresponding eth0:0.
To add multiple IP range, just set up ifcfg-eth0-range1, ifcfg-eth0-range2 in sequence.
Restarting the network after modification is complete:
/ sbin/service network restart