How to add a single IP address in CentOS and add multiple IP addresses in batches
1. Add a single IP Address:
Create a file ifcfg-eth0 in/etc/sysconfig/network-scripts/: *, * is the number, and multiple IP addresses increase in turn
Take 0 as an example to create a file ifcfg-eth0: 0
Cd/etc/sysconfig/network-scripts/
Vi ifcfg-eth0: 0
Input content format:
DEVICE = eth0: 0
TYPE = Ethernet
ONBOOT = yes
BOOTPROTO = static
IPADDR = IP address to be bound
NETMASK = Subnet Mask
GATEWAY = GATEWAY address
After saving, run servicenetworkrestart to restart the network service.
2. Add multiple IP addresses in batches:
Create a file ifcfg-eth0-range0 in/etc/sysconfig/network-scripts/
Vi ifcfg-eth0-range0
Enter the following file content format:
IPADDR_START = start IP Address
IPADDR_END = end IP
CLONENUM_START = 0
Note: The network configurations such as the gateway in the preceding file correspond to the network adapter eth0.
After saving and exiting, run service network restart to restart the network service.