When using the Linux system, we will encounter the problem of configuring multiple IP addresses for a single Nic. If there is no graphical interface under Linux, the configuration is really inconvenient. In the text console, there are netconfig and ifconfig tools in the text console. netconfig is a little more convenient in graphical form, but there is no document, and you can still configure an ip address. However, if you configure multiple IP addresses, you may be confused, only ifconfig can be used
# Ifconfig eth0 192.168.0.1 netmask limit 255.0 up Description: up indicates immediate activation
How can I configure multiple IP addresses for a single network adapter eth0? If the ifconfig command is used, only eth0 needs to be changed. Change eth0 to eth0: x (x is 0-255, for example, eth0: 0 or eth0: 1). eth0: x is called a virtual network interface and is built on a network interface.
Therefore, you can use the following command to configure multiple ip addresses for a single NIC:
# Ifconfig eth0: 0 192.168.0.1 netmask 255.255.255.0 up
# Ifconfig eth0: 1 192.168.0.2 netmask 255.255.255.0 up
After the ping test is passed, the function of configuring multiple ip addresses for a single Nic is completed. In this way, the IP address will be changed back after reboot, so you need to set to automatically activate the IP address setting at startup. The methods are as follows:
First:
Add the above command ifconfig to rc. local.
Second:
Is modeled on/etc/sysconfig/network-scripts/ifcfg-eth0 Add a file named according to the name of the network Virtual Interface, such as ifcfg-eth0: 0 or ifcfg-eth0: 1, etc.
Next Look At The ifcfg-eth0: 0 file configuration information
DEVICE = eth0: 0 # Network Virtual Interface eth0: 0
ONBOOT = yes # activated at startup
BOOTPROTO = static # use a static IP Address
IPADDR = 192.168.0.1 # assign an IP address
NETMASK = 255.255.255.0 # Subnet Mask
Disable an ip address.
# Ifconfig eth0: 0 down