首页 > 系统相关 >Linux 7实现多网卡绑定—bond0方式

Linux 7实现多网卡绑定—bond0方式

时间:2022-12-17 22:00:33浏览次数:46  
标签:00 bond0 forever 192.168 网卡 lft ff Linux brd

文档课题:Linux 7实现多网卡绑定—bond0方式.
系 统:centos 7.9 64位
环境介绍:vmware虚拟机+网卡为NAT模式.
说 明:此次演示bond0,bond地址192.168.133.120
1、添加网卡
添加2块网卡,加上此前网卡共3块网卡.

Linux 7实现多网卡绑定—bond0方式_多网卡绑定

2、关闭networkmanager
--关闭networkmanager服务.
[root@liujun ~]# systemctl disable --now NetworkManager
Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.
Removed symlink /etc/systemd/system/network-online.target.wants/NetworkManager-wait-online.service.
说明:now表示立即关闭NetworkManager服务.
3、网卡配置文件
--修改网卡配置文件,注意网卡名需结合实际情况进行配置.
3.1、网卡原数据
[root@liujun ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:98:c5:5f brd ff:ff:ff:ff:ff:ff
inet 192.168.133.218/24 brd 192.168.133.255 scope global noprefixroute dynamic ens33
valid_lft 1038sec preferred_lft 1038sec
inet6 fe80::e107:1ed3:d4e5:f7ab/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:98:c5:69 brd ff:ff:ff:ff:ff:ff
inet 192.168.133.120/24 brd 192.168.133.255 scope global noprefixroute ens37
valid_lft forever preferred_lft forever
inet6 fe80::e007:4abd:58d:5da3/64 scope link noprefixroute
valid_lft forever preferred_lft forever
4: ens38: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:98:c5:73 brd ff:ff:ff:ff:ff:ff
inet 192.168.133.217/24 brd 192.168.133.255 scope global noprefixroute dynamic ens38
valid_lft 1038sec preferred_lft 1038sec
inet6 fe80::46fe:1c1:a824:9da9/64 scope link noprefixroute
valid_lft forever preferred_lft forever
5: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:a8:7c:6f brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
6: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:a8:7c:6f brd ff:ff:ff:ff:ff:ff
[root@liujun network-scripts]# pwd
/etc/sysconfig/network-scripts
[root@liujun network-scripts]# cat ifcfg-ens37
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens37
UUID=e7191296-fd65-478d-936e-f43dc98f1745
DEVICE=ens37
ONBOOT=yes
IPADDR=192.168.133.120
DNS1=192.168.133.2
GATEWAY=192.168.133.2
PREFIX=24
3.2、修改配置文件
3.2.1、ifcfg-ens37
[root@liujun network-scripts]# vi ifcfg-ens37
按如下修改:
DEVICE=ens37
NAME=ens37
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
[root@liujun network-scripts]# cp ifcfg-ens37 ifcfg-ens33
[root@liujun network-scripts]# cp ifcfg-ens37 ifcfg-ens38
3.2.2、ifcfg-ens33
[root@liujun network-scripts]# vi ifcfg-ens33
按如下修改:
DEVICE=ens33
NAME=ens33
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
3.2.3、ifcfg-ens38
[root@liujun network-scripts]# vi ifcfg-ens38
按如下修改:
DEVICE=ens38
NAME=ens38
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
3.3、配置bond0
[root@liujun network-scripts]# vi ifcfg-bond0
按如下修改
DEVICE=bond0
TYPE=bond0
BONDING_MASTER=yes
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.133.120
NETMASK=255.255.255.0
GATEWAY=192.168.133.2
BONDING_OPTS="mode=0 miimon=100"
BONDING_MASTER=yes
NM_CONTROLLED=no
--加载bond模块
[root@liujun network-scripts]# vi /etc/modprobe.d/bonding.conf
添加如下:
alias bond0 binding
options bond0 miimon=100 mode=0
--开启网卡混杂模式
[root@liujun ~]# chmod +x /etc/rc.local
[root@liujun ~]# vi /etc/rc.local
添加如下内容
ip link set ens33 promisc on
ip link set ens37 promisc on
ip link set ens38 promisc on
4、测试
4.1、移除1块网卡
--重启服务器后,移除其中1块网卡进行测试.
[root@liujun ~]# reboot
[root@liujun ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,PROMISC,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP group default qlen 1000
link/ether 00:0c:29:98:c5:5f brd ff:ff:ff:ff:ff:ff
3: ens37: <BROADCAST,MULTICAST,PROMISC,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP group default qlen 1000
link/ether 00:0c:29:98:c5:5f brd ff:ff:ff:ff:ff:ff
4: ens38: <BROADCAST,MULTICAST,PROMISC,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP group default qlen 1000
link/ether 00:0c:29:98:c5:5f brd ff:ff:ff:ff:ff:ff
5: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:0c:29:98:c5:5f brd ff:ff:ff:ff:ff:ff
inet 192.168.133.120/24 brd 192.168.133.255 scope global bond0
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe98:c55f/64 scope link
valid_lft forever preferred_lft forever
6: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:a8:7c:6f brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
7: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:a8:7c:6f brd ff:ff:ff:ff:ff:ff

说明:如上显示三张网卡,现移除一块测试.

Linux 7实现多网卡绑定—bond0方式_服务器_02

[root@liujun ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,PROMISC,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP group default qlen 1000
link/ether 00:0c:29:98:c5:5f brd ff:ff:ff:ff:ff:ff
4: ens38: <BROADCAST,MULTICAST,PROMISC,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP group default qlen 1000
link/ether 00:0c:29:98:c5:5f brd ff:ff:ff:ff:ff:ff
5: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:0c:29:98:c5:5f brd ff:ff:ff:ff:ff:ff
inet 192.168.133.120/24 brd 192.168.133.255 scope global bond0
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe98:c55f/64 scope link
valid_lft forever preferred_lft forever
6: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:a8:7c:6f brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
7: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:a8:7c:6f brd ff:ff:ff:ff:ff:ff

说明:如上所示,只剩网卡ens33、ens38.
C:\Users\Administrator>ping 192.168.133.120

正在 Ping 192.168.133.120 具有 32 字节的数据:
来自 192.168.133.120 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.133.120 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.133.120 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.133.120 的回复: 字节=32 时间<1ms TTL=64

192.168.133.120 的 Ping 统计信息:
数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
最短 = 0ms,最长 = 0ms,平均 = 0ms

说明:移除其中一张网卡后,依然能ping通服务器.
4.2、移除2张网卡
--接下来在移除一张网卡做测试.
[root@liujun ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,PROMISC,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP group default qlen 1000
link/ether 00:0c:29:98:c5:5f brd ff:ff:ff:ff:ff:ff
5: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:0c:29:98:c5:5f brd ff:ff:ff:ff:ff:ff
inet 192.168.133.120/24 brd 192.168.133.255 scope global bond0
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe98:c55f/64 scope link
valid_lft forever preferred_lft forever
6: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:a8:7c:6f brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
7: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:a8:7c:6f brd ff:ff:ff:ff:ff:ff

说明:如上所示,只剩网卡ens33.
C:\Users\Administrator>ping 192.168.133.120

正在 Ping 192.168.133.120 具有 32 字节的数据:
来自 192.168.133.120 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.133.120 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.133.120 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.133.120 的回复: 字节=32 时间<1ms TTL=64

192.168.133.120 的 Ping 统计信息:
数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
最短 = 0ms,最长 = 0ms,平均 = 0ms

说明:依然能ping通服务器,bond技术有多种,生产环境通常会用到bond4,需结合交换机,设置链路聚合功能.

参考网址:https://www.bilibili.com/video/BV1vD4y1U7db/?spm_id_from=333.337.search-card.all.click&vd_source=8c872e2fd1d99229b38a73ed6718b776

标签:00,bond0,forever,192.168,网卡,lft,ff,Linux,brd
From: https://blog.51cto.com/u_12991611/5950165

相关文章

  • Linux项目部署
    手工部署项目第一步,将所要部署的项目打成jar包第二步,将jar包上传到linux服务器创建目录:mkdir/usr/local/app,输入rz上传jar包第三步,启动springboot程序:在目录下输入......
  • 空间不足了?用linux搭建samba家庭共享盘
    目录背景--空间不够,文件太散乱环境搭建硬盘开机自动挂载samba安装配置参考背景--空间不够,文件太散乱最近在使用各种设备的时候,总是觉得存储空间告急。总觉得现在不太喜......
  • Linux网络命令
    目录ifconfig命令route路由命令ip命令netstat命令ping命令telnet命令ssh命令ifconfig命令用于配置网卡ip地址等网络参数信息,或者查看网络接口信息,类似于windows的ipconfi......
  • Linux的vi/vim指令
    但是目前我们使用比较多的是vim编辑器。vim具有程序编辑的能力,可以主动的以字体颜色辨别语法的正确性,方便程序设计。相关文章:​​史上最全Vim快捷键键位图—入门到进阶......
  • Linux 磁盘管理
    。Linux磁盘管理常用三个命令为df、du和fdis的整体磁盘使用量du(英文全称:diskused):检查磁盘空间使用量fdisk:用于磁盘分区dfdf命令参数功能:检查文件系统的磁盘空间占用情......
  • Linux 文件与目录管理
    Linux的目录结构为树状结构,最顶级的目录为根目录/。其他目录通过挂载可以将它们添加到树中,通过解除挂载可以移除它们。在开始本教程前我们需要先知道什么是绝对路径与相对......
  • Linux 文件基本属性
    Linux系统是一种典型的多用户系统,不同的用户处于不同的地位,拥有不同的权限。为了保护系统的安全性,Linux系统对不同的用户访问同一文件(包括目录文件)的权限做了不同的规定。......
  • Linux 系统目录结构
    登录系统后,在当前命令窗口下输入命令:ls/你会看到如下图所示:树状目录结构:以下是对这些目录的解释:/bin:bin是Binaries(二进制文件)的缩写,这个目录存放着最经常使用的命......
  • Linux学习系列:挂载windows下的磁盘
    一、场景最近在研究双系统(Windows10+Centos7)部署,已经成功将centos7部署起来。因为是双系统,所以要看windows下磁盘的东西,只能挂载到某个目录去查看。本篇博客主要是阐述相关......
  • 1、在自己的腾讯云Linux服务器上配置Sonic
    配置DOCKER配置Docker-compose   ......