Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize dual Network Card bonding under Linux

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article is to share with you about how to achieve dual network card bonding under Linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

The implementation of Linux dual network card binding is to use two network cards to become a virtual network card. Generally speaking, two network cards have the same IP address and parallel links are aggregated into a logical link. In fact, this technology has long existed in Sun and Cisco, known as Trunking and Etherchannel technology, and is also used in the 2.4.x kernel of Linux, known as bonding.

1. Create a bond0 Nic:

Vim / etc/sysconfig/network-scripts/ifcfg-bond0

Add the following:

DEVICE=bond0BOOTPROTO=noneONBOOT=yesNETWORK=192.168.0.0NETMASK=255.255.255.0IPADDR=192.168.0.10USERCTL=noGATEWAY=192.168.0.254TYPE=Ethernet2, modify eth0, eth2

Vim / etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0BOOTPROTO=noneONBOOT=yesMASTER=bond0SLAVE=yesUSERCTL=yes

Vim / etc/sysconfig/network-scripts/ifcfg-eth2

DEVICE=eth2BOOTPROTO=noneONBOOT=yesMASTER=bond0SLAVE=yesUSERCTL=yes3, modify modprobe.conf:

So that kernel can identify it. A setting parameter is added, and the miimon value indicates the time for the two network cards to monitor each other, in ms. The mode value is in working mode, which can be set to high availability or load balancing, 0 is highly available (default), 1 is load balancing, and there is also a XOR mode.

Vim / etc/modprobe.conf

Alias bond0 bondingoptions bond0 miimon=100 mode=1

Description: miimon is used for link monitoring. For example: miimon=100, then the system monitors the link connection status every 100ms, and if one line fails, it will be transferred to another line; the value of mode indicates the working mode. There are four modes: 0meme, 1meme, 2meme, 3, and two are commonly used.

Mode=0 indicates that load balancing (round-robin) is a load balancing method, and both NICs work.

Mode=1 said that fault-tolerance (active-backup) provides redundancy and works in an active and standby mode, that is, by default, only one network card works and the other is backed up.

Bonding can only provide link monitoring, that is, whether the link from the host to the switch is connected. If only the external link down of the switch is down and the switch itself is not down, then bonding will continue to use the link as if there is nothing wrong with it.

4. Adjust the switch, bind multiple ports, and do link aggregation.

The IP of the network card bound to bond under mode 0 is modified to the same mac address. If these network cards are all connected to the same switch, there will be multiple ports corresponding to the mac address in the arp table of the switch. Which port should the switch forward packets destined for this mac address? Normally, mac addresses are unique in the world, and a single mac address corresponds to multiple ports must confuse the switch.

Therefore, if the bond under mode0 is connected to the switch, the ports of the switch should be aggregated (cisco is called ethernetchannel,foundry and portgroup), because after the switch has done aggregation, several ports under the aggregation are also bundled into a mac address.

Thank you for reading! This is the end of the article on "how to achieve dual network card bonding under Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report