重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3072|回复: 0
打印 上一主题 下一主题

[网络管理] CentOS7使用Bond方式,实现网卡绑定

[复制链接]
跳转到指定楼层
楼主
发表于 2020-12-13 16:16:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
(1)实验环境
物理网口:eth0,eth1
绑定后虚拟口:bond0
IP地址:192.168.133.23
网关:192.168.133.2
掩码:255.255.255.0
DNS:8.8.8.8

(2)查看并加载bound

[root@localhost ~]# modprobe --first-time bonding
[root@localhost ~]# lsmod|grep bonding           

bonding               132885  0

加载成功后,可以查看到bond0 端口

[root@localhost ~]# 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
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:94:b5:29 brd ff:ff:ff:ff:ff:ff
    inet 192.168.133.23/24 brd 192.168.133.255 scope global eth0
    inet6 fe80::20c:29ff:fe94:b529/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 00:0c:29:94:b5:33 brd ff:ff:ff:ff:ff:ff
4: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN
    link/ether 66:51:2f:37:a2:31 brd ff:ff:ff:ff:ff:ff

(3)配置虚拟端口bound0

在/etc/sysconfig/network-scripts/目录下,创建ifcfg-bond0文件

vim /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.133.23
NETMASK=255.255.255.0
GATEWAY=192.168.133.2
DNS1=8.8.8.8

(4)配置物理网卡eth0,eth1

vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
MASTER=bond0
SLAVE=yes

vim /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
BOOTPROTO=none
MASTER=bond0

SLAVE=yes

(5)修改modprobe相关设定文件

vim /etc/modprobe.d/bonding.conf
alias bond0 binding

options bond0 miimon=100 mode=0   //模式0,miimon是用来进行链路监测的,后面指定的是检查的间隔时间,单位是ms

(6)重启并测试

[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
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
    link/ether 00:0c:29:94:b5:29 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
    link/ether 00:0c:29:94:b5:29 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:94:b5:29 brd ff:ff:ff:ff:ff:ff
    inet 192.168.133.23/24 brd 192.168.133.255 scope global bond0
    inet6 fe80::20c:29ff:fe94:b529/64 scope link tentative dadfailed

       valid_lft forever preferred_lft forever

查看bonud工作状况:

[root@localhost bonding]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 200
Up Delay (ms): 0
Down Delay (ms): 0

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

Slave Interface: eth1
MII Status: down
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: 00:0c:29:94:b5:33
Slave queue ID: 0

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-11-25 07:00 , Processed in 0.084768 second(s), 20 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表