系统城装机大师 - 固镇县祥瑞电脑科技销售部宣传站!

当前位置:首页 > 系统教程 > Linux教程 > 详细页面

redhat 7.0配置多网卡绑定--学习笔记

时间:2020-02-21来源:系统城作者:电脑系统城

本次实验环境是redhat7.0系统
网卡绑定,不仅可以提高网络传输速度,当一块网卡出现故障时,可以保证服务器依然可以正常使用。网卡绑定有三种模式:

  • mode0(平衡负载模式):两块网卡同时工作,自动做备,但是需要在与服务器本地网卡相连的家换季设备上进行端口聚合来支持绑定技术。
  • mode1(自动主备模式):平时只有一块网卡工作,在它故障后自动替换为另外的网卡
  • mode6(平衡负载模式):平时两块网卡同时工作,自动做备,无须交换设备提供辅助支持

1.1 编辑网卡配置

编辑网卡eno16777736

[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# vim ifcfg-eno16777736 
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
DEVICE=eno16777736
USERCTL=no
MASTER=bond0
SLAVE=yes

编辑网卡eno33554984

[root@localhost network-scripts]# vim ifcfg-eno33554984
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
DEVICE=eno33554984
USERCTL=no
MASTER=bond0
SLAVE=yes

编辑网卡bond0

[root@localhost network-scripts]# vim ifcfg-bond0
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
DEVICE=bond0
IPADDR=192.168.137.10
PREFIX=24
GATEWAY=192.168.137.2
DNS1=114.114.114.114
NM_CONTROLLED=no

配置网卡的驱动文件,使linux内核支持网卡绑定技术,miimon=100是故障自动切换的时间,mode=6选择模式6

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

重启网卡

[root@localhost network-scripts]# systemctl restart network
# 查看网卡信息
[root@localhost network-scripts]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    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: eno16777736: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
    link/ether 00:0c:29:a1:94:b9 brd ff:ff:ff:ff:ff:ff
3: eno33554984: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
    link/ether 00:0c:29:a1:94:b9 brd ff:ff:ff:ff:ff:ff
4: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP 
    link/ether 00:0c:29:a1:94:b9 brd ff:ff:ff:ff:ff:ff
    inet 192.168.137.10/24 brd 192.168.137.255 scope global bond0
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fea1:94b9/64 scope link tentative dadfailed 
       valid_lft forever preferred_lft forever

在另一台ping 192.168.137.10,可以ping通则正常

[root@localhost Desktop]# ping 192.168.137.10
PING 192.168.137.10 (192.168.137.10) 56(84) bytes of data.
64 bytes from 192.168.137.10: icmp_seq=1 ttl=64 time=0.829 ms
64 bytes from 192.168.137.10: icmp_seq=2 ttl=64 time=1.74 ms
64 bytes from 192.168.137.10: icmp_seq=3 ttl=64 time=1.47 ms

将网卡eno16777736删除,在客户端查看ping是否会终断
删除有的网卡配置

[root@localhost network-scripts]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    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
3: eno33554984: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
    link/ether 00:0c:29:a1:94:b9 brd ff:ff:ff:ff:ff:ff
4: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP 
    link/ether 00:0c:29:a1:94:b9 brd ff:ff:ff:ff:ff:ff
    inet 192.168.137.10/24 brd 192.168.137.255 scope global bond0
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fea1:94b9/64 scope link tentative dadfailed 
       valid_lft forever preferred_lft forever

查看客户端的ping结果,依然能ping通,但是在服务器端删除网卡eno16777736时,ping延时增加(175ms),这是正常的现象。

64 bytes from 192.168.137.10: icmp_seq=18 ttl=64 time=0.450 ms
64 bytes from 192.168.137.10: icmp_seq=19 ttl=64 time=1.47 ms
64 bytes from 192.168.137.10: icmp_seq=20 ttl=64 time=1.70 ms
64 bytes from 192.168.137.10: icmp_seq=21 ttl=64 time=175 ms
64 bytes from 192.168.137.10: icmp_seq=22 ttl=64 time=0.939 ms
64 bytes from 192.168.137.10: icmp_seq=23 ttl=64 time=1.60 ms
64 bytes from 192.168.137.10: icmp_seq=24 ttl=64 time=21.2 ms
64 bytes from 192.168.137.10: icmp_seq=25 ttl=64 time=1.35 ms
64 bytes from 192.168.137.10: icmp_seq=26 ttl=64 time=1.06 ms

测试完成

分享到:

相关信息

  • linux 文件权限怎么解析

    常用权限linux系统内有档案有三种身份 u:拥有者 g:群组 o:其他人这些身份对于文档常用的有下面权限:r:读权限,用户可以读取文档的内容,如用cat,more查看w:写权限,用户可以编辑文档x...

    2024-07-07

  • 如何使用WPSeku找出 WordPress 安全问题?

    然而,如果我们遵循通常的 WordPress 最佳实践,这些安全问题可以避免。在本篇中,我们会向你展示如何使用 WPSeku,一个 Linux 中的 WordPress 漏洞扫描器,它可以被用来找出你安装...

    2024-07-03

系统教程栏目

栏目热门教程

人气教程排行

站长推荐

热门系统下载