Linux next NIC How to configure multiple Ip?linux below if there is no graphical interface to configure the network is really not too convenient, oh, habit problems, of course, habits need to change, recently encountered a problem requires a single network adapter to configure multiple IP addresses. Text console has netconfig below, there are ifconfig tools, netconfig graphical slightly more convenient, but there is no document, configure an IP can also cope with, but if the configuration of multiple IP is not possible, can only use the ifconfig, The use of ifconfig can be viewed using man ifconfig, the most commonly used command to configure IP for the NIC
#ifconfig eth0 192.168.0.1 netmask 255.255.255.0 up
Description
Eth0 is the first NIC, and the other is eth1,eth*
192.168.0.1 is the IP address configured for the first NIC configured for the NIC
Netmask 255.255.255.0 is configured with a subnet mask
Up is to indicate immediate activation
If you are configuring multiple IP addresses for a single network adapter eth0, if you use the Ifconfig command, then the only thing that needs to be changed is eth0 This, check some information, understand the eth0 change to Eth0:x (X is 0-255 such as eth0:0 or eth0:1, etc. , Eth0:x called virtual network interface, is built on the network excuse (eth0) above.
So the way to configure multiple IP for a single NIC is to use the command:
#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
#ping 192.168.0.1
#ping 192.168.0.2
The ping test passes, completes the single NIC configuration multiple IP function. Reboot later found that the IP address changed back.
So you must set up automatic activation of IP settings at startup
First type:
Add the above command ifconfig to the rc.local.
The second type:
is to follow/etc/sysconfig/network-scripts/ifcfg-eth0 to add a file name based on the name of the network virtual interface
such as ifcfg-eth0:0 or ifcfg-eth0:1, etc.
#下边看下ifcfg the configuration information inside the-eth0:0 file
device=eth0:0 #网络虚拟接口eth0:0
Onboot=yes #启动的时候激活
Bootproto=static #使用静态ip地址
ipaddr=192.168.0.1 #分配ip地址
netmask=255.255.255.0 #子网掩码
Other configuration files are similar. Restart the ping test for a successful configuration.
Today, I saw the other people did not see the understanding of their own try to know how the specific operation.
How to turn off an IP then use
#ifconfig eth*[:x] Down (* represents the network card number, x represents the virtual connection number 0-255)
To view IP configuration information:
#ifconfig
If there is no understanding or improper place please leave a message! I'm a rookie!