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

The binding process of Linux Nic

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly explains "Linux network card binding process", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn the "Linux network card binding process"!

I. bond mode

Mode=0 (balance-rr) represents a load-sharing round-robin, which cooperates with the aggregation of the switch in a non-negotiated manner.

Mode=1 (active-backup) means active / standby mode. Only one network card is active and the other is standby standby. If the switch is bundled, it will not work properly, because the switch sends packets to two network cards, and half of the packets are discarded.

Mode=2 (balance-xor) represents XOR Hash load sharing, which works with the aggregation of the switch that forces non-negotiation. (xmit_hash_policy required)

Mode=3 (broadcast) means that all packets are sent from all interface, which is unbalanced and only redundant. Cooperate with the aggregation of the switch in a non-negotiated manner.

Mode=4 (802.3ad) indicates that it supports the 802.3ad protocol and works with the aggregation LACP mode of the switch (xmit_hash_policy is required)

Mode=5 (balance-tlb) selects slave to send according to the load of each slave, and uses the current slave when receiving.

Mode=6 (balance-alb) adds rlb to the tlb of 5.

5 and 6 do not need the settings of the switch side, and the network cards can be aggregated automatically. 4 need to support 802.3ad. 0BI 2 and 3 theoretically require static aggregation, but in practice, 0 can be received unevenly without setting up the switch by means of mac address spoofing.

There are three commonly used ones.

Mode=0: load balancing mode, with automatic backup, but requires "Switch" support and setting.

Mode=1: automatic backup mode. If one line is disconnected, the other lines will be backed up automatically.

Mode=6: load balancing mode, automatic backup, no need for "Switch" support and setting.

There is a phenomenon of packet loss under mode=6. Mode=0 is recommended.

II. Linux network port binding

Through the network port binding (bond) technology, it is easy to achieve network port redundancy and load balancing, so as to achieve the goal of high availability and high reliability. Premise agreement:

The two physical network ports are: eth0,eth2

The bound virtual port is: bond0

The server IP is: 192.168.0.100

First, configure the configuration file:

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

TYPE=EthernetDEVICE=bond0BOOTPROTO=noneONBOOT=yesUSERCTL=noIPADDR=192.168.0.100NETMASK=255.255.255.0NETWORK=192.168.0.0BROADCAST=192.168.0.255NM_CONTROLLED=no

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

TYPE=EthernetDEVICE=eth0BOOTPROTO=noneONBOOT=yesMASTER=bond0SLAVE=yesUSERCTL=no

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

TYPE=EthernetDEVICE=eth2BOOTPROTO=noneONBOOT=yesMASTER=bond0SLAVE=yesUSERCTL=no

The second step is to modify the modprobe related settings file and load the bonding module:

Here, we directly create a dedicated settings file / etc/modprobe.d/bonding.conf that loads bonding

[root@test ~] # vi / etc/modprobe.d/bonding.conf

# append

Alias bond0 bonding

Options bonding mode=0 miimon=100

Load module (you don't have to load it manually after restarting the system)

[root@test ~] # modprobe bonding

Verify that the module is loaded successfully:

[root@test ~] # lsmod | grep bonding

Bonding 100065 0

The third step, restart the network, and then confirm the situation: randomly unplug a network cable, and then access your server to see if the network is still open.

[root@test ~] # / etc/init.d/network restart [root@test ~] # cat / proc/net/bonding/bond0Ethernet Channel Bonding Driver: v3.5.0 (November 4,2008) Bonding Mode: fault-tolerance (active-backup) Primary Slave: NoneCurrently Active Slave: eth0. [root@test ~] # ifconfig | grep HWaddrbond0 Link encap:Ethernet HWaddr 00:16:36:1B:BB:74eth0 Link encap:Ethernet HWaddr 00:16:36:1B:BB:74eth2 Link encap:Ethernet HWaddr 00:16:36:1B:BB:74

From the confirmation message above, we can see three important messages:

The current bonding mode is active-backup

Now the network port of Active status is eth0.

The physical address of the bond0,eth2 is the same as that of the eth0 in the active state to avoid confusion on the upper switch.

Step 4: the system starts automatic binding and adds a default gateway:

[root@test ~] # vi / etc/rc.d/rc.local# append ifenslave bond0 eth0 eth2route add default gw 192.168.0.1 III, / etc/modprobe.d/bonding.conf

Note that four network cards are bound to two pairs of network cards. Append cannot be used.

The first: as you can see, in this way, the mode of multiple bond ports can only be set to the same:

Alias bond0 bondingalias bond1 bondingoptions bonding max_bonds=2 miimon=200 mode=1

Second, in this way, the mode of different bond ports can be set to different:

Alias bond0 bondingoptions bond0 miimon=100 mode=1install bond1 / sbin/modprobe bonding-o bond1 miimon=200 mode=0

Meaning of bonding.conf:

Miimon monitors the frequency of network links in milliseconds, which we set to 200ms.

Number of bond ports configured by max_bonds

Mode bond mode, in the general practical application, 0 and 1 are used more.

At this point, I believe you have a deeper understanding of the "Linux Nic binding process". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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

Servers

Wechat

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

12
Report