Linux two NIC sets the same IP address

Source: Internet
Author: User

The dual network adapter is bound to the same virtual network card (bond), the outside world sees as if the bond card is to provide services to the outside world, but in fact, the bottom is two real network cards in the provision of services.


Here are some simple concepts:

1>. Bonding

is to bind multiple NICs to the same IP addresses are available externally to enable high availability or load balancing. Of course, it is not possible to set the same IP address directly for two NICs . Through bonding , a virtual one network card to provide external connections,

the physical NIC is modified to the same MAC address.


2>. Bonding mode of Operation

Mode 0 (BALANCE-RR)

rotation (round-robin) Strategy: send packets above and below each slave interface in a sequential order . This mode provides load balancing and fault tolerance capabilities

Mode 1 (active-backup)

Active - backup (Master) policy: In the binding, only one slave is activated. Other slave are activated when and only if the active slave fails . To prevent the switch from confusing, the bound MAC address is visible on only one external port

Mode 3 (broadcast)

broadcast strategy: All messages are transmitted on all slave interfaces. This mode provides fault-tolerant capability.


We set the two NIC to Mode1 mode with centos6.8

1>. Set the two network card to be bound to a virtual network card, this function may be affected by the NetworkManager service, to first shut down the NetworkManager service, and turn off boot.

[[Email protected] network-scripts]# service NetworkManager stop

Stopping NetworkManager daemon: [OK]

[Email protected] network-scripts]# Chkconfig NetworkManager off


2>. View the IP configuration of the current system

[[email protected] network-scripts]# ifconfigeth0      link  encap:ethernet  hwaddr 00:0c:29:b3:32:cc             inet addr:192.168.203.138  bcast:192.168.203.255  mask : 255.255.255.0          inet6 addr: fe80::20c:29ff : Feb3:32cc/64 scope:link          up broadcast  RUNNING MULTICAST  MTU:1500  Metric:1           RX packets:10486 errors:0 dropped:0 overruns:0 frame:0           TX packets:2862 errors:0 dropped:0  overruns:0 carrier:0          collisions:0  Txqueuelen:1000           rx bytes:869044  (848.6 kib)   TX bytes :417850  (408.0 kib) eth1      link encap:ethernet   Hwaddr 00:0c:29:b3:32:d6            inet  addr:192.168.203.131  Bcast:192.168.203.255  Mask:255.255.255.0           inet6 addr: fe80::20c:29ff:feb3:32d6/64 scope:link           up broadcast running multicast   MTU:1500  Metric:1          RX  packets:8660 errors:0 dropped:0 overruns:0 frame:0           TX packets:686 errors:0 dropped:0 overruns:0 carrier:0           collisions:0 txqueuelen:1000            rx bytes:675217  (659.3 kib)   TX bytes:101974  (99.5 kib)

Obviously, there are two NICs in the system, one is eth0, the other is eth1. Bind the two network cards to a virtual network card.


3> Build and configure configuration files/etc/sysconfig/network-scripts/ifcfg-bond0

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/86/C1/wKioL1fJP-fhOL3wAAAS9A9WW08585.png "title=" bond. PNG "alt=" Wkiol1fjp-fhol3waaas9a9ww08585.png "/>

bonding_opts= "Miimon=100 mode=1"

miimon=100 100ms Detection Once, check if the other side is online

Mode=1 Specifying primary Standby mode


3> Edit the configuration file for two network cards

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/86/C1/wKiom1fJQLizGu_xAAAUDCMdTZA217.png "title=" 5.PNG " alt= "Wkiom1fjqlizgu_xaaaudcmdtza217.png"/>


4> Restart Network Service

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/86/C1/wKioL1fJQSKg1YsZAAAXbBjuwik193.png "title=" Network. PNG "alt=" Wkiol1fjqskg1yszaaaxbbjuwik193.png "/>


5> View information for the BOND0 virtual network card

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/86/C1/wKiom1fJQZrBwc7CAAA2P3pfg68364.png "title=" 3.PNG " alt= "Wkiom1fjqzrbwc7caaa2p3pfg68364.png"/>

Bind the two NIC to a virtual NIC bond0. The experiment has been successful.


6>. Test phase:

A>. The eth0 is closed.

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/86/C1/wKioL1fJQznhf2xBAAAG5kozmAg792.png "title=" capture. PNG "alt=" Wkiol1fjqznhf2xbaaag5kozmag792.png "/>

B> viewing the status of the virtual NIC Bond0

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/86/C1/wKioL1fJQ2aDtEvGAAAm4IcZUqQ112.png "title=" Bond1. PNG "alt=" Wkiol1fjq2adtevgaaam4iczuqq112.png "/>

Eth1 replaced the eth0, which clearly has a high-availability feature.


3>: eth0 start up again.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/86/C1/wKiom1fJRDiBm1dnAAA1-5n0kCw719.png "title=" 21.PNG "alt=" Wkiom1fjrdibm1dnaaa1-5n0kcw719.png "/>

The eth0 becomes the standby NIC, and eth1 becomes the network card being used.

Linux two NIC sets the same IP address

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.