RHEL配置多網(wǎng)卡9步精通
在RHEL配置多網(wǎng)卡利用bonding可以實(shí)現(xiàn)將多張物理網(wǎng)卡綁定成一個(gè)虛擬的接口,這個(gè)虛擬的接口可以看作一個(gè)正常的網(wǎng)絡(luò)接口,可以用這個(gè)接口為單位來進(jìn)行網(wǎng)絡(luò)通訊。
1、RHEL配置多網(wǎng)卡添加bonding driver,2.4.12以上的kernel默認(rèn)都提供了。
如果沒有,可以如下操作:
1)、make menuconfig,找到Bonding driver support
2)、install內(nèi)核和模塊
2、RHEL配置多網(wǎng)卡添加alias bond0 bonding到/etc/modprobe.conf,這樣我們配置bond0接口的時(shí)候,bonding driver就會(huì)自動(dòng)載入。
3、RHEL配置多網(wǎng)卡在/etc/sysconfig/network-scripts目錄配置bond0,文件名為ifcfg-bond0。
內(nèi)容如下
DEVICE=bond0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.1.2
NETMASK=255.255.255.248
GATEWAY=192.168.1.1
4、配置eth3,如下,eth4類似
DEVICE=eth3
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
5、RHEL配置多網(wǎng)卡模塊參數(shù)。
只用了
◆miimon:對(duì)link監(jiān)控的周期,單位是ms,默認(rèn)為0,建議為100
◆mode:bonding的策略,只要有負(fù)載均衡(0);主備(1)等
還有諸如arp_interval,max_bonds等參數(shù)
6、配置模塊參數(shù),我的配置如下
◆options bond0 miimon=100 mode=1
7、重啟服務(wù)器,用ifconfig可以看到bond0
8、查看bond0狀態(tài)
more /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v2.6.0 (January 14, 2004)
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth3
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth3
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0c:76:26:2b:3d
Slave Interface: eth4
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:10:b5:b4:56:84
9、最后
1)、我本來想使用模式0,但是工作起來有些異常,發(fā)現(xiàn)同網(wǎng)段服務(wù)器的ping值在3-10ms之間,還伴隨著丟包,如果用了模式1,ping值就會(huì)小于1ms,穩(wěn)定而不丟包,不知道為什么。
2)、第一次使用的時(shí)候,如果用ping,可以看到(DUP!)的提示,應(yīng)該是正常的,原因是:
This is not due to an error in the bonding driver, rather, it is a side effect of how many switches update their MAC forwarding tables. Initially, the switch does not associate the MAC address in the packet with a particular switch port, and so it may send the traffic to all ports until its MAC forwarding table is updated. Since the interfaces attached to the bond may occupy multiple ports on a single switch, when the switch (temporarily) floods the traffic to all ports, the bond device receives multiple copies of the same packet (one per slave device).
3)、也可以用ifenslave來實(shí)現(xiàn)RHEL配置多網(wǎng)卡。
筆者在此文利用了10步驟來講述了RHEL配置多網(wǎng)卡的操作過程。
【編輯推薦】