美文网首页
Linux 双网卡绑定

Linux 双网卡绑定

作者: DB哥 | 来源:发表于2020-04-15 16:19 被阅读0次

关于网卡绑定模式简介

mode值表示工作模式,共有0\1\2\3\4\5\6\7这7种模式,常用的为0\1\6三种。

mode=0表示load balancing (round-robin)为负载均衡方式,两块网卡都工作。
mode=1表示fault-tolerance (active-backup)提供冗余功能,工作方式是主备的工作方式,也就是说默认情况下只有一块网卡工作,另一块做备份.
mode=2表示balance-x,提供负载均衡和冗余功能。
mode=3表示broadcast,这个模式提供容错性。
mode=4表示802.3ad,提供了ethtool的迅速,以及使用了802.3ad模式
mode=5表示balance-tlb,自动适应负载均衡,自动切换故障。在此基础上Ethtool支持驱动。
mode=6表示在5模式的基础上优化了arp的广播信息。

常用的网卡绑定驱动模式有:

mode0平衡负载模式(高可用):平时两块网卡均工作,且自动备援,采用交换机设备支援。 #==》不推荐使用
mode1自动备援模式(热备):平时只有一块网卡工作,故障后自动替换为另外的网卡。   #==》推荐使用
mode6平衡负载模式(高可用):平时两块网卡均工作,且自动备援,无须交换机设备支援   #==》推荐使用

环境配置说明:
VMware Workstation 安装CentOS 7操作系统,并添加两块虚拟网卡

image.png
Linux System Environment
[root@test001 ~]# cat /etc/redhat-release                       #==》系统版本
CentOS Linux release 7.5.1804 (Core)
[root@test001 ~]# uname –r                                  #==》系统内核
3.10.0-862.el7.x86_64
[root@test001 ~]# uname -m                                #==》系统位数
x86_64
[root@test001 ~]# echo $LANG                              #==》系统字符集
en_US.UTF-8

网卡绑定模式 mode=1操作步骤

一、创建虚拟聚合网卡接口

[root@test001 ~]# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-bond0
[root@test001 ~]# vim /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0             #==》设备名称
BOOTPROTO=none                #==》手动配置IP地址,也可以设置static
IPADDR=192.168.201.109           #==》IP地址
NETMASK=255.255.255.0           #==》子网掩码
NETWORK=192.168.201.254         #==》网关
BROADCAST=192.168.201.255       #==》广播地址
DNS=192.168.201.10               #==》DNS
ONBOOT=yes                     #==》网卡自启动
USERCTL=no                     #==》是否允许普通用户管理此接口
BONDING_OPTS="miimon=100 mode=1"  #==》配置双网卡模式为1(热备功能),miimon=100网卡切换时间在100毫秒

二、修改第一张网卡eth0配置信息
注意:一定要按照以下配置修改,不用保留UUID等配置

[root@test001 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0       #==》master设备名指定虚拟聚合网卡接口名称
SLAVE=yes           #==》开启SLAVE功能
USERCTL=no         #==》是否允许普通用户管理此接口

三、修改第二张网卡eth1配置信息
注意:一定要按照以下配置修改,不用保留UUID等配置

[root@test001 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0    #==》master设备名指定虚拟聚合网卡接口名称
SLAVE=yes         #==》开启SLAVE功能
USERCTL=no       #==》是否允许普通用户管理此接口

四、重启网卡
注意:如果重启网卡不生效,请重启系统

[root@test001 ~]# systemctl restart network

五、查看状态
注意:如果测试可以使用ping命令进行测试

[root@test001 ~]# 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: eth0
MII Status: up
MII Polling Interval (ms): 10
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:87:b5:f0
Slave queue ID: 0

Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:87:b5:fa
Slave queue ID: 0

[root@test001 ~]# ethtool bond0
Settings for bond0:
        Supported ports: [ ]
        Supported link modes:   Not reported
        Supported pause frame use: No
        Supports auto-negotiation: No
        Supported FEC modes: Not reported
        Advertised link modes:  Not reported
        Advertised pause frame use: No
        Advertised auto-negotiation: No
        Advertised FEC modes: Not reported
        Speed: 1000Mb/s
        Duplex: Full
        Port: Other
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: off
        Link detected: yes

网卡绑定模式 mode=6操作步骤与上面操作步骤一样,唯一区别在于bond0网卡配置信息把mode修改成 mod=6即可

一、创建虚拟聚合网卡接口

[root@test001 ~]# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-bond0
[root@test001 ~]# vim /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0             #==》设备名称
BOOTPROTO=none                #==》手动配置IP地址,也可以设置static
IPADDR=192.168.201.109           #==》IP地址
NETMASK=255.255.255.0           #==》子网掩码
NETWORK=192.168.201.254         #==》网关
BROADCAST=192.168.201.255       #==》广播地址
DNS=192.168.201.10               #==》DNS
ONBOOT=yes                     #==》网卡自启动
USERCTL=no                     #==》是否允许普通用户管理此接口
BONDING_OPTS="miimon=100 mode=6"  #==》配置双网卡模式为1(热备功能),miimon=100网卡故障切换时间在100毫秒

二、重启网卡
注意:如果重启网卡不生效,请重启系统

[root@test001 ~]# systemctl restart network

三、查看状态
注意:如果测试可以使用ping命令进行测试

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

Bonding Mode: adaptive load balancing
Primary Slave: None
Currently Active Slave: eth0
MII Status: up
MII Polling Interval (ms): 10
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:87:b5:f0
Slave queue ID: 0

Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:87:b5:fa
Slave queue ID: 0

[root@test001 ~]# ethtool bond0
Settings for bond0:
        Supported ports: [ ]
        Supported link modes:   Not reported
        Supported pause frame use: No
        Supports auto-negotiation: No
        Supported FEC modes: Not reported
        Advertised link modes:  Not reported
        Advertised pause frame use: No
        Advertised auto-negotiation: No
        Advertised FEC modes: Not reported
        Speed: 2000Mb/s
        Duplex: Full
        Port: Other
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: off
        Link detected: yes

相关文章

  • 【Linux】双网卡绑定

    前言:作为一个DBA,我们日常工作也会涉及到一些linux系统运维的工作,比如说今天要讲的双网卡绑定。 一、理论知...

  • Linux 双网卡绑定

    关于网卡绑定模式简介 mode值表示工作模式,共有0\1\2\3\4\5\6\7这7种模式,常用的为0\1\6三种...

  • Linux下双网卡绑定

    由于工作关系,需要进行双网卡绑定,之前单纯认为网卡绑定就是把两个网口通过配置的改变合并成一个网口,没有多复杂。详细...

  • Centos7 多网卡绑定实现负载均衡

    常见绑定模式 以双网卡配置示例

  • 双网卡绑定

    一台服务器同时有安装双网卡,要对网卡进行配置。即进行双网卡绑定。 概念:网卡:一块被设计用来允许计算机在计算机网络...

  • Linux实现双网卡绑定和卸载

    双网卡绑定实现就是使用两块网卡虚拟成为一块网卡,这个聚合起来的设备看起来是一个单独的以太网接口设备,通俗点讲就是两...

  • Linux双网卡绑定实现高可用

    看看一般情况下网卡基本配置是怎么样的? 使用DHCP自动获取IP: vim /etc/sysconfig/netw...

  • ubuntu配置bond

    配置 简介与准备工作 bond简介 Linux双网卡绑定实现就是使用两块网卡虚拟成为一块网卡,这个聚合起来的设备看...

  • Redhat7通过bond技术实现双网卡绑定

    redhat 7虽然新增了teaming技术支持双网卡绑定,但bonding技术依然可以沿用,不过与redhat ...

  • CentOS双网卡双IP设置

    CentOS双网卡双IP设置 系统环境:CentOS Linux 网络环境: 两个IP地址,192.168.0.2...

网友评论

      本文标题:Linux 双网卡绑定

      本文链接:https://www.haomeiwen.com/subject/ddcklhtx.html