欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 运维知识 > linux >内容正文

linux

Gnu/Linux网卡绑定bonding

发布时间:2024/1/17 linux 48 豆豆
生活随笔 收集整理的这篇文章主要介绍了 Gnu/Linux网卡绑定bonding 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

系统:    CentOS或RHEL5系列系统
配置文件:/etc/modprobe.conf
----------------------------------------
系统:    CentOS或RHEL6系列系统
配置文件:/etc/modprobe.d/dist.conf

Linux bonding提供将多个网络接口设备捆绑为单个网络接口设置来使用,
用于网络负载均衡及网络冗余。

网卡绑定主要有0~6七种模式,常用的有3种:
      

1 2 3 4 5 0:负载均衡,两个网卡都工作,当一个出现问题后,另一个还继续工作,    需要在交换机做端口聚合配置,因为两块网卡使用的是同一个MAC地址;     1:主备模式,同时只有一张网卡工作;    6:负载均衡,两个网卡都工作,但是该模式下无需配置交换机,因为做bonding的    两块网卡是使用不同的MAC地址;

 

一、检查系统是否支持网卡绑定

1 2 3 4 5 6 7 8 9 10 11 #modinfo bonding ilename:        /lib/modules/3.0.13-0.27-xen/kernel/drivers/net/bonding/bonding.ko alias:          rtnl-link-bond author:         Thomas Davis, tadavis@lbl.gov and many others description:    Ethernet Channel Bonding Driver, v3.7.1 version:        3.7.1 license:        GPL srcversion:     7A8A0EF8B35B2DE05BC5E19 depends:         supported:      yes vermagic:       3.0.13-0.27-xen SMP mod_unload modversions Xen

 

有信息输出,说明系统支持,如不支持,需要重新编译内核,找到Bonding driver support。你的输出信息可能与这里不同,不过没关系。

 

二、建立绑定端口配置文件

1 2 3 4 5 6 7 8 9 10 11 12 # cd /etc/sysconfig/network-scripts # cp -a ifcfg-eth0 ifcfg-bond0 # vi ifcfg-bond0 # Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet DEVICE=bond0            #修改设备名称为bond0,一定要去掉HWADDR网卡硬件地址 BOOTPROTO=none          #修改为none或static ONBOOT=yes              #修改成yes IPADDR=192.168.56.100   #网卡IP地址 NETMASK=255.255.255.0   #网卡掩码 GATEWAY=192.168.56.1    #网关地址 DNS1=192.168.56.254     #DNS地址

 

三、修改物理网卡配置文件

以将eth0和eth1进行网卡绑定为例:

1 2 3 4 5 6 7 8 # vi ifcfg-eth0 # Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet DEVICE=eth0TYPE=Ethernet BOOTPROTO=none     #修改成none或static ONBOOT=yes         #修改成yes MASTER=bond0       #指定主设备名称 SLAVE=yes
1 2 3 4 5 6 7 8 # vi ifcfg-eth1 # Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet DEVICE=eth1TYPE=Ethernet BOOTPROTO=none ONBOOT=yes MASTER=bond0 SLAVE=yes


四、加载模块

1 2 3 # vim /etc/modprobe.conf alias bond0bonding                 #bond0为定义绑定网卡设备名称 options bonding mode=0 miimon=100  #负载均衡模式,每100ms检查一次网卡状态


如果是RHEL6系列的系统,配置文件是/etc/modprobe.d/dist.conf,或者自己手动创建配置文件,

如,/etc/modprobe.d/bond0.conf等。


五、注意事项

最好绑定的两个物理网卡型号一样,网卡都属于同一个网段。

 

六、临时绑定,即时生效

1 2 3 # ifconfig bond0 192.168.56.100 netmask 255.255.255.0 up # ifenslave bond0 eth0 # ifenslave bond0 eth1


本文转自   bigstone2012  51CTO博客,原文链接:http://blog.51cto.com/lavenliu/1441325

总结

以上是生活随笔为你收集整理的Gnu/Linux网卡绑定bonding的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。