A virtual IP address (VIP) is an IP address that is not connected to a particular computer or to a network interface card (NIC) in a computer. The packet is sent to the VIP address, but all the data is passed through the actual network interface. VIPs is mostly used for connection redundancy; A VIP address may also be available when one computer or NIC fails, and is sent to another optional computer or NIC to respond to the connection. Examples of virtual IP addresses are: a loopback (no circuit IP address) as an IP address that is not associated with any particular interface (or circuit) in the host or router. IP technology, enhance network management, play the advantages of VLAN, change the network structure, reasonable allocation of network resources, balanced Network load, effectively reduce the online broadcast information, convenient for users of the group management. Linux configuration Virtual IP address method
In daily Linux management work, need to configure a separate IP address for the application to achieve the separation between the host and the application, in the application of switching and migration can be dynamic switch, especially when using Ha, this scheme can ensure that the host and application isolation, the daily operations have great benefits.
However, in some applications have not been configured Ha, later need to configure Ha, we can first configure the virtual IP to the online application use, which later system operations can achieve better scalability.
This article is mainly about how to configure the IP address to do some simple introduction, only a record memo. hehe.
PS: The following instances are in the Redhat Linux Successful implementation!
1. Configure virtual IP online
Ifconfig eth0:1 192.168.109.108 netmask 255.255.255.0
2. Check that the newly added sub-interface configuration information is correct. mainly look at the IP with the subnet mask.
Ifconfig eth0:1
# ifconfig Eth0:1
Eth0:1 Link encap:ethernet HWaddr 00:0c:29:45:62:3b
inet addr:192.168.109.108 bcast:192.168.109.255 mask:255.255.255.0
Up broadcast RUNNING multicast mtu:1500 metric:1
Base address:0x2000 memory:d8920000-d8940000
3. start the sub-interface of the NIC Eth0
Ifconfig eht0:1 up
See if IP can be interconnected
Ping-c 3 192.168.109.108
# ping-c 3 192.168.109.108
PING 192.168.109.108 (192.168.109.108) bytes of data.
Bytes from 192.168.109.108:icmp_seq=1 ttl=64 time=0.032 ms
Bytes from 192.168.109.108:icmp_seq=2 ttl=64 time=0.053 ms
Bytes from 192.168.109.108:icmp_seq=3 ttl=64 time=0.036 ms
---192.168.109.108 ping statistics---
3 Packets transmitted, 3 received, 0% packet loss, time 2000ms
RTT Min/avg/max/mdev = 0.032/0.040/0.053/0.010 ms
4. Modify the configuration file so that the configuration automatically takes effect after the host restarts.
cd/etc/sysconfig/network-script/
CP Ifcfg-eth0 Ifcfg-eth0:1
VI ifcfg-eth0:1
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
Device=eth0:1----> Sub-interface Name
hwaddr=00:0c:29:45:62:3b
Onboot=yes
Bootproto=static
ipaddr=192.168.109.108
netmask=255.255.255.0
5. to switch between the host IP and the application IP can do the following processing
As the following example: Host IP is 192.168.109.105 application IP is 192.168.109.108
We're going to swap the IP,
192.168.109.108 for host use
192.168.109.105 for application use
The procedure is as follows:
Pre-configuration information:
#ifconfig eth0
Eth0 Link encap:ethernet HWaddr 00:0c:29:45:62:3b
inet addr:192.168.109.105 bcast:192.168.109.255 mask:255.255.255.0
Inet6 ADDR:FE80::20C:29FF:FE45:623B/64 Scope:link
Up broadcast RUNNING multicast mtu:1500 metric:1
RX packets:20340 errors:0 dropped:0 overruns:0 frame:0
TX packets:16678 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1800154 (1.7 mib) TX bytes:2438822 (2.3 MiB)
Base address:0x2000 memory:d8920000-d8940000
# ifconfig Eth0:1
Eth0:1 Link encap:ethernet HWaddr 00:0c:29:45:62:3b
inet addr:192.168.109.108 bcast:192.168.109.255 mask:255.255.255.0
Up broadcast RUNNING multicast mtu:1500 metric:1
Base address:0x2000 memory:d8920000-d8940000
Modify Eth0:1 configuration information for the NIC:
# VI Ifcfg-eth0:1
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
Device=eth0:1----> Sub-interface Name
hwaddr=00:0c:29:45:62:3b
Onboot=yes
Bootproto=static
ipaddr=192.168.109.105
netmask=255.255.255.0
Modify Eth0 configuration information for the NIC:
#vi Ifcfg-eth0
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
Device=eth0
hwaddr=00:0c:29:45:62:3b
Onboot=yes
Bootproto=static
ipaddr=192.168.109.108
netmask=255.255.255.0
Restart Network effective: This step is very important!!!
Nohup Service Network Restart &
Submit the command to the background to execute, this way can ensure that the system restart the network normally
PS: Best for production systems in the consoleon the operation, or there is an exception to the cup with ...
Virtual IP Configuration