首页 > 系统相关 >Linux系统之Bonding网卡绑定配置方法

Linux系统之Bonding网卡绑定配置方法

时间:2023-02-03 12:32:49浏览次数:58  
标签:Server001 network Linux RX 网卡 Bonding scripts root

(Linux系统之Bonding网卡绑定配置方法)

一、检查本地系统环境

1.检查系统版本

[root@Server001 ~]# cat /etc/os-release 
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

2.查看服务器网卡

[root@Server001 network-scripts]# ifconfig  -a
bond0: flags=5123<UP,BROADCAST,MASTER,MULTICAST>  mtu 1500
        inet 192.168.30.122  netmask 255.255.255.0  broadcast 192.168.30.255
        ether a6:ad:e5:84:f0:6e  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.3.55  netmask 255.255.255.0  broadcast 192.168.3.255
        inet6 fe80::2a6e:d4ff:fe89:8720  prefixlen 64  scopeid 0x20<link>
        ether 28:6e:d4:89:87:20  txqueuelen 1000  (Ethernet)
        RX packets 2256  bytes 439140 (428.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 428  bytes 68770 (67.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::2a6e:d4ff:fe8a:3299  prefixlen 64  scopeid 0x20<link>
        ether 28:6e:d4:8a:32:99  txqueuelen 1000  (Ethernet)
        RX packets 1617  bytes 386452 (377.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 7  bytes 586 (586.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::2a6e:d4ff:fe88:f490  prefixlen 64  scopeid 0x20<link>
        ether 28:6e:d4:88:f4:90  txqueuelen 1000  (Ethernet)
        RX packets 1617  bytes 386452 (377.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 7  bytes 586 (586.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0



二、创建网卡配置文件

1.进入网卡配置文件目录

[root@Server001 ~]# cd /etc/sysconfig/network-scripts/
[root@Server001 network-scripts]# ls
ifcfg-bond0  ifdown-eth   ifdown-ppp       ifdown-tunnel  ifup-ippp   ifup-post    ifup-TeamPort      network-functions-ipv6
ifcfg-eth0   ifdown-ippp  ifdown-routes    ifup           ifup-ipv6   ifup-ppp     ifup-tunnel
ifcfg-lo     ifdown-ipv6  ifdown-sit       ifup-aliases   ifup-isdn   ifup-routes  ifup-wireless
ifdown       ifdown-isdn  ifdown-Team      ifup-bnep      ifup-plip   ifup-sit     init.ipv6-global
ifdown-bnep  ifdown-post  ifdown-TeamPort  ifup-eth       ifup-plusb  ifup-Team    network-functions

2.拷贝eth0的网卡配置文件

[root@Server001 network-scripts]# cp ifcfg-eth0 ifcfg-eth1
[root@Server001 network-scripts]# cp ifcfg-eth0 ifcfg-eth2
[root@Server001 network-scripts]# cp ifcfg-eth0 ifcfg-bond0

3.修改bond0网卡配置文件

[root@Server001 network-scripts]# cat ifcfg-bond0 
DEVICE=bond0
BOOTPROTO=none
TYPE=bond0
ONBOOT=yes
IPADDR=192.168.30.122
NETMASK=255.255.255.0

4.修改eth1网卡配置文件

[root@Server001 network-scripts]# cat ifcfg-eth1
DEVICE=eth1
BOOTPROTO=none
TYPE=Ethernet
MASTER=bond0
SLAVE=yes


5.修改eth2网卡配置文件

[root@Server001 network-scripts]# cat ifcfg-eth2
DEVICE=eth2
BOOTPROTO=none
TYPE=Ethernet
MASTER=bond0
SLAVE=yes

三、创建bonding的配置文件

1.编辑bonding.conf

[root@node network-scripts]# vim /etc/modprobe.d/bonding.conf
[root@node network-scripts]# cat /etc/modprobe.d/bonding.conf
alias bond0 bonding
options bonding mode=1 miimon=100

注:关于mode的说明 mode=0 //平衡循环 mode=1 //主备 mode=3 //广播 mode=4 //链路聚合

2.停止 NetworkManager 服务

systemctl stop NetworkManager
systemctl disable NetworkManage

3.加载 bonding 模块

[root@Server001 network-scripts]# lsmod |grep bonding
[root@Server001 network-scripts]#  modprobe bonding
[root@Server001 network-scripts]#  lsmod |grep bonding
bonding               152656  0 

4.重启网络服务

systemctl restart network

四、查看网卡绑定情况

1.再次检查本地网卡

[root@Server001 network-scripts]# ifconfig 
bond0: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST>  mtu 1500
        inet 192.168.30.122  netmask 255.255.255.0  broadcast 192.168.30.255
        inet6 fe80::2a6e:d4ff:fe8a:3299  prefixlen 64  scopeid 0x20<link>
        ether 28:6e:d4:8a:32:99  txqueuelen 1000  (Ethernet)
        RX packets 2426  bytes 748394 (730.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 13  bytes 838 (838.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.3.55  netmask 255.255.255.0  broadcast 192.168.3.255
        inet6 fe80::2a6e:d4ff:fe89:8720  prefixlen 64  scopeid 0x20<link>
        ether 28:6e:d4:89:87:20  txqueuelen 1000  (Ethernet)
        RX packets 2853  bytes 740694 (723.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 478  bytes 75189 (73.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500
        ether 28:6e:d4:8a:32:99  txqueuelen 1000  (Ethernet)
        RX packets 2229  bytes 689858 (673.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 13  bytes 838 (838.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth2: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500
        ether 28:6e:d4:8a:32:99  txqueuelen 1000  (Ethernet)
        RX packets 2243  bytes 690766 (674.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

2.查看网卡绑定状态

[root@Server001 network-scripts]# cat  /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth1
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth1
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 28:6e:d4:8a:32:99
Slave queue ID: 0

Slave Interface: eth2
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 28:6e:d4:88:f4:90
Slave queue ID: 0

五、测试网卡连通情况

1.本地客户端ping服务器

ping 192.168.30.122

image.png

六、关闭eth1网卡测试连通情况

1.关闭eth1网卡

[root@Server001 network-scripts]# ifdown eth1
[root@Server001 network-scripts]# 

2.查看本地客户端连通情况

可以正常ping通 image.png

3.查看当前的bond0状态

当前活动网卡已经切换到eth2,eth2网卡提供服务

[root@Server001 network-scripts]# cat  /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth2
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth2
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 28:6e:d4:88:f4:90
Slave queue ID: 0

七、关闭eth2网卡测试连通情况

1.开启eth1网卡,关闭eth2网卡

[root@Server001 network-scripts]# ifup eth1
[root@Server001 network-scripts]# ifdown eth2

2.测试本地客户端连通情况

可以正常ping通

image.png

3.查看当前的bond0状态

当前活动网卡已经切换到eth1,eth1网卡提供服务

[root@Server001 network-scripts]# cat  /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth1
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth1
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 28:6e:d4:8a:32:99
Slave queue ID: 0

标签:Server001,network,Linux,RX,网卡,Bonding,scripts,root
From: https://blog.51cto.com/u_14664141/6035774

相关文章

  • Linux 配置Tomcat、SpringBoot项目开机自启
    Linux配置Tomcat、SpringBoot项目开机自启#javaenvironment指定java环境exportJAVA_HOME=/home/jdk1.8.0_11exportCLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAV......
  • Linux内核的配置与裁减
    一、内核的配置和编译流程:1)编写driver及其子目录下的Kconfig文件,将驱动的配置项写入menuconfig配置界面;2) 执行makemenuconfig命令,进入内核配置界面,将对应的驱动程序配......
  • (笔记)NTP时间同步失败:Windows(W32Time)作为NTP时钟源服务端,Linux作为客户端
     一、问题现象使用windows(W32Time)作NTP时钟源服务端,控制板端Linux作为客户端,使用ntpd服务无法同步时间,但是ntpdate是可以同步成功。 二、问题分析 1.从报文的角度分......
  • Linux系统如何解压rar文件
    1、下载linux版本的rar软件访问[官方地址](https://www.rarlab.com/download.htm)下载最新版本的linux版本rar软件wgethttps://www.rarlab.com/rar/rarlinux-x6......
  • Linux下重启Oracle数据库
    1、Linux下以Oracle帐户进入Linux系统。su -oracle   ---切换成oracle用户登录2、执行以下命令查看数据库监听器的状况:lsnrctlstatus3、执行以下命令停止数据库监......
  • 设置和修改Linux的swap分区大小解决内存不足问题
    一、创建1.查看当前分区情况free-m2.增加swap大小,2G左右ddif=/dev/zeroof=/var/swapbs=1024count=20480003.设置交换文件mkswap/var/swap4.立......
  • Linux五大网络模型之I/O多路复用浅入深出
    网上寻得一篇讲解LinuxI/O模型很好的文章,特此引用。文章摘录自:https://new.qq.com/rain/a/20210610A05G9600正文:基本概念我们先来了解几个基本概念。什么是I/O?所谓......
  • Linux快速搭建tensorflow-gpu 1.15.0环境&Keras
    Linux快速搭建tensorflow-gpu1.15.0环境&Keras========================condacreate-ntf115-cconda-forgetensorflow-gpu=1.15condainstallkeras==2.3.1 激......
  • linux驱动移植-DM9000网卡驱动
    在学习Mini2440裸机程序时,我们介绍过关于DM9000网卡的相关知识,包括电路图、以及DM9000寄存器等信息。具体可以参考Mini2440裸机开发之DM9000。本节对之前已经介绍过的知识......
  • linux基本功系列-ls命令实战
    前言今天起开始学习基础命令,linux常用命令比较多,先从文件和目录查询命令开始,第一个ls命令;先看看我的学习环境吧:接下来进入正题,一起学习下ls命令的使用:一.ls命令的介......