Get the App
SLTechnology News&Howtos  ›  Servers  › 

Server: add IP to network card in batch under Centos system

Shulou Source: shulou.com Published: 2022-06-03 08:54:46 11月14日 Update

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

Tags: Systems network cards content networks servers services examples aliases can be passed through commands addresses multiple that is values numbers files gateways order subnets Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple vpn macOS Microsoft Redmi