Tangxiang Daily-March 16, 2017:
How to add multiple IP addresses to a NIC in Linux network configuration
There are two common ways that Linux systems configure VIPs for network cards: alias IP, and secondary IP
=======================================
Aliases IP (alias IP)
The IP alias is created and maintained by the Ifconfig command of the Linux system, and the alias IP is the second and higher IP that is bound on the NIC device.
Description: The configuration of the alias IP will be abandoned in the future Linux system, because there will be no more ifconfig commands in the future system.
①. Methods for manually configuring aliases for VIPs
Ifconfig eth0:1 10.0.0.100 netmask 255.255.255.224 up
Route add-host 10.0.0.100 Dev eth0---Add a host route, optional configuration
Description: The IP alias configuration is temporary and will be lost once the NIC is restarted
②. How to Manually view VIP aliases
Ifconfig
③. How to manually delete an alias VIP
Ifconfig eth0:1 10.0.0.100 netmask 255.255.255.224 down
Ifconfig eth0:1 Down
④. Method for permanent alias IP
Write to the network card profile to make the alias IP permanent, the name can be ifcfg-eth0:x,x 0-255 of any number, IP and other content formats and Ifcfg-eth0 consistent
Vim/etc/sysconfig/network-scripts/ifcfg-eth0:1
Device=eth0:1
ipaddr=10.0.0.100
Secondary IP (secondary IP address)
The secondary IP is created and maintained by the IP command of the Linux system, and the IP addr add is created as a secondary IP and cannot be viewed through ifconfig.
But the alias IP created by Ifconfig can be viewed in the IP addr Show command
Description: Need to focus on the master ※
①. Methods for manually configuring aliases for VIPs
IP addr Add 10.0.0.100/24 dev eth0
IP addr Add 10.0.0.101/24 broadcast 10.0.0.255 dev eth0
IP addr Add 10.0.0.101/24 broadcast 10.0.0.255 dev eth0 label eth0:0
②. How to Manually view VIP aliases
IP addr
③. How to manually delete an alias VIP
IP addr del 10.0.0.100/24 dev eth0
IP addr del 10.0.0.101/24 broadcast 10.0.0.255 Dev eth0
VIP Configuration Summary:
1. heartbeat2.1.4 and previously used alias ip,heartbeat2.1.4 later use is the secondary IP, provide VIP services
2. Keepalived has always been used as an auxiliary IP service
How to add multiple IP addresses to a NIC in Linux network configuration