How to configure multiple IP and detect IP conflict in Linux system

Time:2020-7-15

Configure a series of IP

In Linux, if you configure multiple IP addresses, it is usually eth0.0.. eth0.1.. eth0. X, and so on. If you want to configure a large number of IP addresses, this configuration is OK, but tedious, although this situation is rare.
For adding a large number of IP, there are certain regulations. The RHCE / CentOS system provides a fast way to bind an IP range, so that we no longer need to create a large number of files, saving time. For example:

Copy code

The code is as follows:

# vim /etc/sysconfig/network-scripts/ifcfg-eth0-range0
IPADDR_START=10.1.0.100
IPADDR_END=10.1.0.200
CLONENUM_START=0
NETMASK=255.255.255.0

IPADDR_ Start is the first IP, IPADDR_ End is the last IP. CLONENUM_ Start is the start number that will be assigned to a series of interfaces (starting with eth0:0 in this instance).
Activate network card:

Copy code

The code is as follows:

# ifdown eth0 && ifup eth0

Detect IP conflicts
Having an IP address conflict means that more than one network device or computer has the same IP address. When configuring IP for the server, if the IP address planning is not done well in the early stage, and the IP address usage details are registered, it is possible to allocate the reused IP to another server.
So how to detect IP address conflicts?
You can use the ARP scan tool. The tool sends ARP packets in LAN to collect IP and MAC address information. If an IP address corresponds to multiple MAC addresses, it indicates that there is an IP conflict.
1. Installation:

Copy code

The code is as follows:

# yum install arp-scan

To install the EPEL source first.
2. Use:
201615120147993.jpg (670×462)