Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to bind and configure bond Network Card in Linux

Shulou Source: shulou.com Published: 2022-06-01 06:39:11 10月30日 Update

This article mainly introduces how to bind and configure bond network cards in Linux. The article is very detailed and has certain reference value. Interested friends must read it!

It can be configured successfully with one command. I configured it on vm8.0 virtual machine.

1. Create bond network card file

Create ifcfg-bond0 in/etc/sysconfig/network-scripts/directory

Command: vi /etc/sysconfig/network-scripts/ifcfg-bond0

Or copy the physical NIC: cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-bond0

2. Configure the NIC to bind

Write bond0 eth2 eth3

Use the command vi /etc/sysconfig/network-scripts/ifcfg-bond0 (ifcfg-bond 0 is the name of the network card, if you want to write other network cards, you can modify the name)

The final results are as follows:

The code is as follows:

#cat ifcfg-bond0

DEVICE=bond0

ONBOOT=yes

IPADDR=10.128.1.11

NETMASK=255.255.255.0

GATEWAY=10.128.1.11

USERCTL=no

The configuration of the two network cards to be bound here is the same

The code is as follows:

#cat ifcfg-eth2

DEVICE=eth2

ONBOOT=yes

MASTER=bond0

bootproto=none

#cat ifcfg-eth3

DEVICE=eth3

ONBOOT=yes

MASTER=bond0

bootproto=none

3. Modify modprobe.conf

vi /etc/modprobe.conf

Add:

alias bond0 bonding

options hond miimon=100 mode=1

#miimon is used for link monitoring. For example:miimon=100, then the system monitors the connection status every 100ms, and if one line is blocked, it will switch to another line;

There are seven Bonding modes:

#defineBOND_MODE_ROUNDROBIN 0 (balance-rr mode) Load Balancer mode of NIC

#defineBOND_MODE_ACTIVEBACKUP 1 (active-backup mode) Fault-tolerant mode of NIC

#defineBOND_MODE_XOR 2 (balance-xor mode) requires switch support

#defineBOND_MODE_BROADCAST 3 (broadcast mode)

#defineBOND_MODE_8023AD 4 (IEEE 802.3ad Dynamic Link Aggregation Mode) requires switch support

#defineBOND_MODE_TLB 5 Adaptive Transfer Load Balancer Mode

#defineBOND_MODE_ALB 6 Network card virtualization mode

4. Modify rc.local

vi /etc/rc.d/rc.local

Add: ifenslave bond0 eth0 eth2

5. Yes. Network card in effect.

Command: Service network restart

Or directly execute reboot (this command is generally not recommended in production environments, but it can be executed in tests, and general problems can be solved. I love to reboot.

The above is "How to bind and configure bond network card in Linux" All the contents of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!

Tags: Network card mode configuration command equalization switch code content name article line link support monitoring success value interest dynamic buddy partner Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Tech Info macOS Docker Shulou Information