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

Using CSS to implement image frame animation and curve motion

The basic principle of all animations is to displ...

How to solve nginx 503 Service Temporarily Unavailable

Recently, after refreshing the website, 503 Servi...

Tomcat server security settings method

Tomcat is an HTTP server that is the official ref...

Debian virtual machine created by VirtualBox shares files with Windows host

the term: 1. VM: Virtual Machine step: 1. Downloa...

How to mark the source and origin of CSS3 citations

I am almost going moldy staying at home due to th...

Analysis of the use of Linux vulnerability scanning tool lynis

Preface: Lynis is a security audit and hardening ...

VMware Workstation Installation (Linux Kernel) Kylin Graphic Tutorial

This article shares with you how to install Kylin...

...

A brief discussion on the design and optimization of MySQL tree structure tables

Preface In many management and office systems, tr...

MYSQL METADATA LOCK (MDL LOCK) theory and lock type test

Table of contents MYSQL METADATA LOCK (MDL LOCK) ...

Summary of principles for writing HTML pages for emails

Since HTML email is not an independent HOST page o...

Detailed explanation of CentOS configuration of Nginx official Yum source

I have been using the CentOS purchased by Alibaba...

How to optimize images to improve website performance

Table of contents Overview What is Image Compress...