Linux uses dual network card bond and screwdriver interface

Linux uses dual network card bond and screwdriver interface

What is bond

NIC bond is a technology that is commonly used in production scenarios. It combines multiple NICs into one logical NIC to achieve local NIC redundancy, bandwidth expansion, and load balancing.

Applicable scenarios

The two network cards of the server need to be bonded, and after bonding, the network cards need to be configured with addresses of different network segments to carry different traffic. At this time, the sub-interface method can be used.

Experimental scenario

equipment

  • Server: Server_A
  • Core switches: Switch_A, Switch_B

Switch connection mode: stacking

Server network card: enp176s0f0, enp176s0f1 as bond

IP segmentation

  • Business segment
    VLAN 201: 10.10.51.0/24
  • Public Network
    VLAN 401: 111.20.200.88/27

Require

The two core switches Switch_A and Switch_B connected to server Server_A are stacked. The enp176s0f0 and enp176s0f1 optical ports of Server_A are interconnected with Switch_A and Switch_B respectively. It is now required that enp176s0f0 and enp176s0f1 be bonded, the address 10.10.51.16 carries business traffic, the address 111.20.200.90 carries public network traffic, and the switch ports are bound as eth-trunk and transparently transmit VLAN201 and VLAN401.

Network card configuration script

# Stop the NetworkManager service systemctl stop NetworkManager.service 
systemctl disable NetworkManager.service

# Backup cp /etc/sysconfig/network-scripts/ifcfg-enp176s0f0{,.bak}
cp /etc/sysconfig/network-scripts/ifcfg-enp176s0f1{,.bak}

# Change the network card protocol to none and start the device automatically without powering on, and configure dual network cards sed -i 's/BOOTPROTO=dhcp/BOOTPROTO=none/' /etc/sysconfig/network-scripts/ifcfg-enp176s0f0
sed -i 's/ONBOOT=no/ONBOOT=yes/' /etc/sysconfig/network-scripts/ifcfg-enp176s0f0
echo "MASTER=bond0" >>/etc/sysconfig/network-scripts/ifcfg-enp176s0f0
echo "SLAVE=yes" >>/etc/sysconfig/network-scripts/ifcfg-enp176s0f0

sed -i 's/BOOTPROTO=dhcp/BOOTPROTO=none/' /etc/sysconfig/network-scripts/ifcfg-enp176s0f1
sed -i 's/ONBOOT=no/ONBOOT=yes/' /etc/sysconfig/network-scripts/ifcfg-enp176s0f1
echo "MASTER=bond0" >>/etc/sysconfig/network-scripts/ifcfg-enp176s0f1
echo "SLAVE=yes" >>/etc/sysconfig/network-scripts/ifcfg-enp176s0f1

# Configure network card bond0
echo "DEVICE=bond0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=static" >/etc/sysconfig/network-scripts/ifcfg-bond0

# Write module file, bond mode is mode 0
echo "alias bond0 bonding
options bond0 miimon=100 mode=0" >/etc/modprobe.d/bond.conf
# Load module modprobe bonding

# Screwdriver interface bond0.201
echo "DEVICE=bond0.201
TYPE=Vlan
PHYSDEV=bond0
ONBOOT=yes
BOOTPROTO=static
REORDER_HDR=yes
IPADDR=10.10.51.16
GATEWAY=10.10.51.1
NETMASK=255.255.255.0
DNS1=114.114.114.114
DNS2=8.8.8.8
VLAN=yes
VLAN_ID=201" >/etc/sysconfig/network-scripts/ifcfg-bond0.201

# Screwdriver interface bond0.401
echo "DEVICE=bond0.401
TYPE=Vlan
PHYSDEV=bond0
ONBOOT=yes
BOOTPROTO=static
REORDER_HDR=yes
IPADDR=111.20.200.90
GATEWAY=111.20.200.89
NETMASK=255.255.255.0
DNS1=114.114.114.114
DNS2=8.8.8.8
VLAN=yes
VLAN_ID=401" >/etc/sysconfig/network-scripts/ifcfg-bond0.401

# Load the module and restart the host modprobe 8021q
reboot

Key Points

If the switch side starts with eth-trunk, the server side must start with a sub-interface

The switch side and the server side should either both enable lacp negotiation or not, otherwise the ports will be different.

Example for configuring the eth-trunk port on the switch

[HH2B108-H01-2-HW9006X-SW001-Eth-Trunk12]display this 
#
interface Eth-Trunk12
port link-type trunk
port trunk allow-pass vlan 201 401
#
return

The server side starts the LACP protocol using bond mode 4. The example is as follows

 # more /etc/modprobe.d/bond.conf
 alias bond0 bonding
 options bond0 miimon=100 mode=4 lacp_rate=1

The VLAN number in "DEVICE=bond0.401" in the sub-interface configuration file must be consistent with the VLAN number that needs to be transparently transmitted.

After configuring the sub-interface, you must restart the server for it to take effect! ! !

Summarize:

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support for 123WORDPRESS.COM.

You may also be interested in:
  • Linux system dual network card binding configuration implementation
  • Linux dual network card binding script method example
  • Configuration process of dual network card firewalld under Linux (recommended)
  • Detailed explanation of Linux dual network card binding to achieve load balancing
  • How to set up dual network cards in Linux
  • Summary of the practice of dual network card configuration under Linux system
  • Linux uses bond to implement dual network cards to bind a single IP sample code

<<:  Summary of common optimization operations of MySQL database (experience sharing)

>>:  Ajax jquery realizes the refresh effect of a div on the page

Recommend

Example code for hiding element scrollbars using CSS

How can I hide the scrollbars while still being a...

Explanation of the concept and usage of Like in MySQL

Like means "like" in Chinese, but when ...

Jenkins packaging microservices to build Docker images and run them

Table of contents Environment Preparation start 1...

37 Tips for a Good User Interface Design (with Pictures)

1. Try to use single column instead of multi-colum...

Details of Linux file descriptors, file pointers, and inodes

Table of contents Linux--File descriptor, file po...

A preliminary understanding of CSS custom properties

Today, CSS preprocessors are the standard for web...

Detailed explanation of the problem of CSS class names

The following CSS class names starting with a num...

Summary of CSS front-end knowledge points (must read)

1. The concept of css: (Cascading Style Sheet) Ad...

Example code for implementing photo stacking effect with CSS

Achieve results step 1. Initial index.html To bui...

Website background music implementation method

For individual webmasters, how to make their websi...

Summary of common commands for Linux user and group management

This article summarizes the common commands for L...

How to monitor and delete timed out sessions in Tomcat

Preface I accidentally discovered that the half-h...

Linux uses binary mode to install mysql

This article shares the specific steps of install...