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

news2024/9/29 7:27:38

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

  • 一、检查本地系统环境
    • 1.检查系统版本
    • 2.查看服务器网卡
  • 二、创建网卡配置文件
    • 1.进入网卡配置文件目录
    • 2.拷贝eth0的网卡配置文件
    • 3.修改bond0网卡配置文件
    • 4.修改eth1网卡配置文件
    • 5.修改eth2网卡配置文件
  • 三、创建bonding的配置文件
    • 1.编辑bonding.conf
    • 2.停止 NetworkManager 服务
    • 3.加载 bonding 模块
    • 4.重启网络服务
  • 四、查看网卡绑定情况
    • 1.再次检查本地网卡
    • 2.查看网卡绑定状态
  • 五、测试网卡连通情况
    • 1.本地客户端ping服务器
  • 六、关闭eth1网卡测试连通情况
    • 1.关闭eth1网卡
    • 2.查看本地客户端连通情况
    • 3.查看当前的bond0状态
  • 七、关闭eth2网卡测试连通情况
    • 1.开启eth1网卡,关闭eth2网卡
    • 2.测试本地客户端连通情况
    • 3.查看当前的bond0状态

一、检查本地系统环境

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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/174674.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

OneFlow v0.9.0正式发布

今天是 OneFlow 开源的第 903 天&#xff0c;OneFlow v0.9.0 正式发布。本次更新包含 640 个 commit&#xff0c;完整更新列表请查看链接&#xff1a;https://github.com/Oneflow-Inc/oneflow/releases/tag/v0.9.0&#xff0c;欢迎下载体验新版本&#xff0c;期待你的反馈。One…

Java补充内容(Junit 反射 注解)

1 Junit测试 测试分类&#xff1a; 1. 黑盒测试&#xff1a;不需要写代码&#xff0c;给输入值&#xff0c;看程序是否能够输出期望的值。 2. 白盒测试&#xff1a;需要写代码的。关注程序具体的执行流程。 Junit使用&#xff1a;白盒测试 步骤&#xff1a; 定义一个测试类(测试…

机器学习知识总结——18.实现一个简单的K-Means聚类

文章目录引用库生成样本数据训练K-Means实验在上一章节里简要的介绍了无监督学习中聚类的知识点&#xff0c;看的太多理论概念&#xff0c;难免会有点莫名其妙&#xff0c;现在就让我们来实现一个简单的 K-Means 算法&#xff0c;从而从原理上彻底弄明白聚类是怎么工作的。 引…

YOLO v2主要看这些重点

来源&#xff1a;投稿 作者&#xff1a;ΔU 编辑&#xff1a;学姐 往期内容&#xff1a; YOLOv1学习笔记 论文 《YOLO9000:Better, Faster, Stronger》 Joseph Redmon∗†, Ali Farhadi∗† University of Washington∗ , Allen Institute for AI† http://pjreddie.com/…

计算机视觉OpenCv学习系列:第五部分、颜色操作

第五部分、颜色操作第一节、颜色表操作1.查找表LUT(look up table)2.颜色查找表&#xff08;1&#xff09;Gamma校正&#xff08;2&#xff09;OpenCV默认的查找表3.代码练习与测试&#xff08;1&#xff09;多种颜色查找表&#xff08;2&#xff09;滚动条颜色查找表第二节、随…

23种设计模式(十四)——中介者模式【接口隔离】

文章目录 意图什么时候使用中介者真实世界类比中介者模式的实现中介者模式的优缺点亦称:调解人、控制器、Intermediary、Controller、Mediator 意图 用一个中介者对象来封装一系列的对象交互。使得各对象不需要显式地相互引用,从而使其松散耦合,而且可以独立地改变它们之间…

新书预告:人机环境系统智能

东方算计&#xff1a;象者&#xff0c;像也西方计算&#xff1a;逻辑 or 实证人工智能是数学物理的产物&#xff0c;而数学是不完备的&#xff0c;物理仍是在探索中&#xff0c;所以人工智能存在着先天不足&#xff0c;有着大量的脆弱和缺点&#xff0c;具体而言&#xff0c;包…

7、矩阵的创建

目录 一、希尔伯特&#xff08;Hilbert&#xff09;矩阵 二、托普利兹&#xff08;Toeplitz&#xff09;矩阵 三、0&#xff5e;1间均匀分布的随机矩阵 四、标准正态分布随机矩阵 五、魔方矩阵 六、帕斯卡矩阵 七、范德蒙&#xff08;Vandermonde&#xff09;矩阵 MATLA…

机器学习——基本概念

小谈&#xff1a;一直想整理机器学习的相关笔记&#xff0c;但是一直在推脱&#xff0c;今天发现知识快忘却了&#xff08;虽然学的也不是那么深&#xff09;&#xff0c;但还是浅浅整理一下吧&#xff0c;便于以后重新学习。最近换到新版编辑器写文章了&#xff0c;有的操作挺…

跨平台freebasic集锦(1)-安装与概述

目录TIOBE Index for January 2023概述特点BASIC兼容性干净的语法多平台Unicode支持大量内置数据类型用户定义类型&#xff08;UDT&#xff09;默认过程参数值内联汇编Intel语法传统的预处理器支持调试支持创建OBJ、LIB、DLL和控制台或GUI EXE优化代码生成下载安装TIOBE Index …

Java设计模式-迭代器模式、迭代器模式是什么、怎么使用

继续整理记录这段时间来的收获&#xff0c;详细代码可在我的Gitee仓库SpringBoot克隆下载学习使用&#xff01; 6.9 迭代器者模式 6.9.1 定义 提供一个对象来顺序访问聚合对象中的一系列数据&#xff0c;而不暴露聚合对象的内部表示 6.9.2 结构 抽象聚合(Aggregate)角色&a…

[创业之路-48] :动态股权机制 -3- 静态股权分配 VS 动态股权分配

静态的股权分配是基础&#xff0c;动态的股权分配才是灵魂&#xff1a;只要你给了固态股权&#xff0c;比如说&#xff0c;股东A在最开始出资100万&#xff0c;占了10%的股份&#xff0c;但是&#xff0c;在后面的工作种&#xff0c;因为能力问题&#xff0c;价值观问题&#x…

回收租赁商城系统功能拆解12讲-会员权益

回收租赁系统适用于物品回收、物品租赁、二手买卖交易等三大场景。 可以快速帮助企业搭建类似闲鱼回收/爱回收/爱租机/人人租等回收租赁商城。 回收租赁系统支持智能评估回收价格&#xff0c;后台调整最终回收价&#xff0c;用户同意回收后系统即刻放款&#xff0c;用户微信零…

【自然语言处理】词袋模型在文本分类中的用法

词袋模型在文本分类中的用法1.加载数据 20 Newsgroups&#xff1a;数据被组织成 20 个不同的新闻组&#xff0c;每个新闻组对应一个不同的主题。一些新闻组彼此非常密切相关&#xff08;例如 comp.sys.ibm.pc.hardware / comp.sys.mac.hardware&#xff09;&#xff0c;而其他…

云原生之Docker容器的存储管理

一、检查本地docker环境 1.检查宿主机系统版本 [rootdocker ~]# cat /etc/centos-release CentOS Linux release 7.6.1810 (Core) 2.检查docker版本 [rootdocker ~]# docker -v Docker version 20.10.18, build b40c2f6二、创建一个测试httpd容器 1.创建测试目录 [rootdoc…

Python版本PathPlanning运动规划库中RotationToWorldFrame函数内部计算过程分析

本文主要对Python版本PathPlanning运动规划库中RotationToWorldFrame函数的内部计算过程分析&#xff0c;包括相关必备python基础和计算过程分析两部分&#xff0c;并给出了等效的MATLAB版本计算过程程序&#xff0c;方便分析对比。 &#xff08;注&#xff1a;RotationToWorld…

【春节旅游攻略】南京周边出发,小众又好玩的景点推荐

【写在前面】 过年了&#xff0c;今天咱不谈技术&#xff0c;聊聊轻松的话题&#xff0c;旅游&#xff0c;其实博主很喜欢去外面走走看的&#xff0c;特汇总了一个4天3晚的旅行攻略&#xff0c;说走就走&#xff0c;带上自己的亲人多看看外面的锦世繁华。 三人行&#xff0c;…

使用最小二乘法和最大似然法估计非线性模型

专注系列化、高质量的R语言教程推文索引 | 联系小编 | 付费合集本文是年前的最后一篇推文&#xff0c;我们来学习一下使用最小二乘法和最大似然法进行非线性模型估计。模型估计是指&#xff0c;在模型形式已知的情况下&#xff0c;求解出可以使已有数据与模型形式最大程度上相符…

【日常系列】LeetCode《28·动态规划3》

数据规模->时间复杂度 <10^4 &#x1f62e;(n^2) <10^7:o(nlogn) <10^8:o(n) 10^8<:o(logn),o(1) 内容 二维数组中的路径问题 买卖股票的最佳时机 lc 62【剑指 098】【top100】&#xff1a;不同路径 https://leetcode.cn/problems/unique-paths/ 提示&#x…

分享优秀的视频地址

【2022 RISC-V中国峰会-芯来演讲合集】https://www.bilibili.com/video/BV1mV4y1W785?vd_source733efcf14020a43e7dac58e4c28ca0c8【计算机组成与设计&#xff1a;RISC-V【浙江大学】】https://www.bilibili.com/video/BV1tz411z7GN?vd_source733efcf14020a43e7dac58e4c28ca0…