博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
多网卡捆绑bonding
阅读量:6536 次
发布时间:2019-06-24

本文共 3451 字,大约阅读时间需要 11 分钟。

多网卡bonding实验

生产环境中将多块网卡绑定同一IP地址对外提供服务,可以实现高可用或者负载均衡。直接给两块网卡设置同一IP地址是不可以的。通过bonding,虚拟一块网卡对外提供连接,物理网卡被修改为相同的MAC地址

实验环境:

centos7主机一台、网卡设备2块。

此次实验通过两种方式来实现bonding,第一种为修改配置文件,第二种为命令行


修改配置文件实现bonding

一、创建band0配置文件

[root@centos7 ~]# vim /etc/sysconfig/network-scripts/ifcfg-bond0DEVICE=bond0IPADDR=192.168.172.100PREFIX=24BONDING_OPTS='miimon=100 mode=1'

二、配置第一块网卡

[root@centos7 ~]#vim /etc/sysconfig/network-scripts/ifcfg-ens33TYPE=EthernetDEVICE=ens33ONBOOT=yesMASTER=bond0SLAVE=yes

三、配置第二块网卡

[root@centos7 ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens37TYPE=EthernetDEVICE=ens37ONBOOT=yesMASTER=bond0SLAVE=yes

四、重启网络服务

[root@centos7 ~]# systemctl restart network

五、查看bond状态

[root@centos7 ~]# cat /proc/net/bonding/bond0 Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)Bonding Mode: fault-tolerance (active-backup)Primary Slave: NoneCurrently Active Slave: ens33MII Status: upMII Polling Interval (ms): 100Up Delay (ms): 0Down Delay (ms): 0Slave Interface: ens33MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: 00:0c:29:63:21:a6Slave queue ID: 0Slave Interface: ens37MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: 00:0c:29:63:21:b0Slave queue ID: 0

命令行实现bonding

一、创建bond0

[root@centos7 ~]# nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ipv4.method manual ipv4.addresses 192.168.172.100Connection 'bond0' (6a323a49-1f74-4424-aa90-8dde22bba989) successfully added.

二、将ens33及ens37加入bond0

[root@centos7 ~]# nmcli connection add type bond-slave ifname ens33 master bond0 Connection 'bond-slave-ens33' (ecacd740-fe79-43a8-9c99-190d17663d01) successfully added.[root@centos7 ~]# nmcli connection add type bond-slave ifname ens37 master bond0 Connection 'bond-slave-ens37' (ea66c3cf-66b5-4438-ad97-058d70c25c28) successfully added.

三、将ens33及ens37关联至bond0

[root@centos7 ~]# nmcli connection up bond-slave-ens33Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)[root@centos7 ~]# nmcli connection up bond-slave-ens37Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)

四、启用bond0

[root@centos7 ~]# nmcli connection up bond0

五、查看bonding状态

[root@centos7 ~]# cat /proc/net/bonding/bond0 Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)Bonding Mode: fault-tolerance (active-backup)Primary Slave: NoneCurrently Active Slave: ens33MII Status: upMII Polling Interval (ms): 100Up Delay (ms): 0Down Delay (ms): 0Slave Interface: ens33MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: 00:0c:29:63:21:a6Slave queue ID: 0Slave Interface: ens37MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: 00:0c:29:63:21:b0Slave queue ID: 0

删除bonding

1.禁用bond0

[root@centos7 ~]# nmcli connection down bond0Connection 'bond0' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/8)

2.删除bond相关链接

[root@centos7 ~]# nmcli connection delete bond0Connection 'bond0' (6a323a49-1f74-4424-aa90-8dde22bba989) successfully deleted.[root@centos7 ~]# nmcli connection delete bond-slave-ens33Connection 'bond-slave-ens33' (ecacd740-fe79-43a8-9c99-190d17663d01) successfully deleted.[root@centos7 ~]# nmcli connection delete bond-slave-ens37Connection 'bond-slave-ens37' (ea66c3cf-66b5-4438-ad97-058d70c25c28) successfully deleted.

转载于:https://blog.51cto.com/11886307/2372975

你可能感兴趣的文章
单例模式(Singleton)
查看>>
函数指针和指针函数
查看>>
Python的函数参数传递:传值?引用?
查看>>
[转]分享2011年8个最新的jQuery Mobile在线教程
查看>>
android call require api level
查看>>
创建Visual Studio项目模版向导的几篇参考文章
查看>>
深入浅出SQL Server Replication第一篇:走近Replication(上)
查看>>
[TopCoder][SRM] SRM 562 DIV 2
查看>>
SQLSERVER是怎麽通过索引和统计信息来找到目标数据的(第一篇)
查看>>
LocalAlloc,VirtualAlloc,malloc,new的异同
查看>>
回调函数
查看>>
win7 x64 jdk1.7.0_51
查看>>
linux中利用iptables+geoip过滤指定IP
查看>>
在myeclipse中写sql语句的细节问题
查看>>
使用ShellExecute打开目标文件所在文件夹并选中目标文件
查看>>
HDU 4614 Vases and Flowers (2013多校2 1004 线段树)
查看>>
Minix中的字符判定ctype.c
查看>>
91平台iOS接入demo
查看>>
用js实现table内容从下到上连续滚动
查看>>
JVM学习笔记(一)------基本结构
查看>>