How to add a single IP address and multiple IP addresses in CentOS
1. Add a single IP Address
1. Enter/etc/sysconfig/network-scripts/to create a file ifcfg-eth0: *, * is the number, multiple IP increases in turn
Take 0 as an example to create a file ifcfg-eth0: 0
#cd/etc/sysconfig/network-scripts/
#viifcfg-eth0:0
2. Enter the content in the following format:
DEVICE = eth0: 0 TYPE = Ethernet ONBOOT = yes BOOTPROTO = static IPADDR = IP address to be bound NETMASK = subnet mask GATEWAY = GATEWAY address
3. After saving, run service network restart to restart the IP address added by the network service.
#servicenetworkrestart
2. Add multiple IP addresses in batches
1. Enter/etc/sysconfig/network-scripts/to create a file ifcfg-eth0-range0
#viifcfg-eth0-range0
2. Enter the content in the following format:
DEVICE = eth0 ONBOOT = yes BOOTPROTO = static IPADDR_START = start IP address IPADDR_END = end IP address CLONENUM_START = 0 GATEWAY = GATEWAY address NETMASK = subnet mask NO_ALIASROUTING = yes
3. After saving and exiting, run service network restart to restart the network service.
#servicenetworkrestart