Bind multiple IP addresses to a single NIC in linux

Source: Internet
Author: User
In linux, a single NIC is bound to multiple IP addresses. note: a single NIC is bound to two IP addresses, including China Telecom and China Unicom. The purpose is to ensure that China Unicom works normally when China Telecom fails. System IP address subnet mask gateway CentOS6.3 _ 64biteth0: 116.18.176.1920.255.0192.168.1.1eth0: 0... in linux, a single NIC is bound to multiple IP addresses. note: a single NIC is bound to two IP addresses, including China Telecom and China Unicom. The purpose is to ensure that China Unicom works normally when China Telecom fails. System IP address subnet mask gateway CentOS 6.3_64biteth0: 116.18.176.1920.255.0192.168.1.1eth0: 0: 172.188.174.2020.255.0192.168.1.1 ......... 1. the storage path of linux network devices is/etc/sysconfig/network-scripts. enter the directory: [root @ localhost ~] # Cd/etc/sysconfig/network-scripts/[root @ localhost network-scripts] # lltotal 196-rw-r -- r --. 1 root 212 Mar 20 ifcfg-eth0 2. create a ifcfg-eth0 in the/etc/sysconfig/network-scripts directory: x (x can be, 2 .......).
For ease we can talk about ifcfg-eth0, copy a Copy named ifcfg-eth0: 0, and then modify the configuration file. [Root @ localhost network-scripts] # cp ifcfg-eth0.0 ifcfg-eth0: 0 3, edit ifcfg-eth0: 0 virtual IP [root @ localhost network-scripts] # vim ifcfg-eth0: 0 DEVICE = "eth0: 0 "// modify the device name BOOTPROTO =" static "// [none | static | bootp | dhcp] (Protocol not used during boot | static score
Configuration | BOOTP protocol | DHCP protocol) IPADDR = 172.188.174.20 // modify the IP address NETMASK = 255.255.255.0 // subnet mask GATEWAY = 192.168.1.1 // gateway broadcast = '2017. 168.1.255 '// broadcast address HWADDR = "00: 0C: 29: C9: 6D: 11" // MAC address NM_CONTROLLED = "yes" ONBOOT = "yes" // boot activation: if you need to bind another IP address to wq, you only need to add the file name to eth0: x in the DEVICE in the file. 4. configure the Nic DNS (China Telecom and China Unicom) configuration file under/etc/resolv. conf. Vim/etc/resolv. confnameserver 202.109.14.5 # save and exit DNS for the master DNSnameserver 219.141.136.10 # times, and then run the following command to restart the virtual Nic. [Root @ localhost network-scripts] # service network restart or/etc/init. d/network restart 5. let's check if our virtual Nic is activated. use ifconfig, that is, the following. [Root @ localhost network-scripts] # ifconfigeth0 Link encap: Ethernet HWaddr 00: 0C: 29: C9: 6D: 18 inet addr: 116.18.176.19 Bcast: 192.168.1.255 Mask: 255.255.255.0 inet6 addr: fe80: 20c: 29ff: fec9: 6d18/64 Scope: Link up broadcast running multicast mtu: 1500 Metric: 1 RX packets: 1622 errors: 0 dropped: 0 overruns: 0 frame: 0 TX packets: 702 errors: 0 dropped: 0 overruns: 0 carrier: 0 collisions: 0 txqueuelen: 1000 RX bytes: 170181 (166.1 KiB) TX bytes: 122357 (119.4 KiB) eth0: 0 Link encap: Ethernet HWaddr 00: 0C: 29: C9: 6D: 18 inet addr: 172.188.174.20 Bcast: 192.168.1.255 Mask: 255.255.255.0 up broadcast running multicast mtu: 1500 Metric: 1 lo Link encap: Local Loopback inet addr: 127.0.0.1 Mask: 255.0.0.0 inet6 addr: 1/128 Scope: host up loopback running mtu: 16436 Metric: 1 RX packets: 0 errors: 0 dropped: 0 overruns: 0 frame: 0 TX Packets: 0 errors: 0 dropped: 0 overruns: 0 carrier: 0 collisions: 0 txqueuelen: 0 RX bytes: 0 (0.0 B) TX bytes: 0 (0.0 B) 6. run the following test. another computer uses ping to test C: \ Users \ Administrator> ping 116.18.176.19. pinging 116.18.176.19 with 32 bytes of data: reply from 116.18.176.19: byte = 32 time = 16 ms TTL = 64 replies from 116.18.176.19: Byte = 32 time = 8 ms TTL = 255 replies from 116.18.176.19: byte = 32 time = 8 ms TTL = 255 replies from 116.18.176.19: Byte = 32 time = 8 ms TTL = 255 C: \ Users \ Adminis Trator> ping 172.188.174.20 is pinging 172.188.174.20 with 32 bytes of data: reply from 172.188.174.20: Byte = 32 time = 16 ms TTL = 64 reply from 172.188.174.20: byte = 32 time = 8 ms TTL = 255 replies from 172.188.174.20: Byte = 32 time = 8 ms TTL = 255 replies from 172.188.174.20: byte = 32 time = 8 ms TTL = 255 test successful! 7. test whether eth0: 0 is normally used when eth0 is interrupted. C: \ Users \ Administrator> ping 116.18.176.19. pinging 116.18.176.19 with 32 bytes of data: The request timed out. Request Timeout. Request Timeout. Reply from 192.168.1.2: the target host cannot be accessed. C: \ Users \ Administrator> ping 172.188.174.20 pinging 172.188.174.20 with 32 bytes of data: reply from 172.188.174.20: Byte = 32 time = 16 ms TTL = 64 reply from 172.188.174.20: byte = 32 time = 8 ms TTL = 255 replies from 172.188.174.20: Byte = 32 time = 8 ms TTL = 255 replies from 172.188.174.20: byte = 32 time = 8 ms TTL = 255 test successful!
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.