RHEL5 雙網卡綁定設置詳解
由於市場上大多數服務器都標配2-4個網口,通常情況下只會採用其中一個,爲了資源的充分利用及防止網卡故障,
推薦大家採用bonding技術,注意真實環境中交換機對應的兩個網口也要做配置哦!
一、編輯虛擬網絡接口配置文件,指定網卡信息
[root@crushlinux ~]# vi /etc/sysconfig/network-scripts/ifcfg-bond0 DEVICE=bond0 BOOTPROTO=none BONBOOT=yes IPADDR=192.168.1.254 NETMASK=255.255.255.0 GATEWAY=192.168.1.1 NETWORK=192.168.1.0 USERCTL=no
二、配置真實網卡eth0,eth1
[root@crushlinux ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 BOOTPROTO=none ONBOOT=yes MASTER=bond0 SLAVE=yes USERCTL=yes [root@crushlinux ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth1 DEVICE=eth1 BOOTPROTO=none ONBOOT=yes MASTER=bond0 SLAVE=yes USERCTL=yes
三、加載模塊,讓系統支持bonding
[root@crushlinux ~]# mv /etc/modprobe.conf /etc/modprobe.conf.bak [root@crushlinux ~]# vi /etc/modprobe.conf alias eth0 bnx2 alias eth1 bnx2 alias scsi_hostadapter aacraid alias scsi_hostadapter1 ata_piix alias bond0 bonding options bond0 miimon=100 mode=1 primary=eth0
說明:
mode指定了bond0的工作模式,常用的是0和1,0表示負載均衡方式,1表示主備方式。
mode=0表示 load balancing (round-robin)爲負載均衡方式,兩塊網卡都工作。
mode=1表示 fault-tolerance (active-backup)提供冗餘功能,工作方式是主備方式,默認情況一塊網卡工作,另一塊做備份。
bonding只提供鏈路監測,從主機到交換機的鏈路是否接通。如果交換機對外的鏈路down掉了,
而交換機本身沒有故障,那麼bonding會認爲鏈路沒有問題而繼續使用。
miimon是用來進行鏈路監測的。
比如:miimon=100,那麼系統每100ms監測一次鏈路連接狀態,如果有一條線路不通就轉入另一條線路。
四、增加開機啓動腳本
[root@crushlinux ~]# vi /etc/rc.d/rc.local 末行加入 ifenslave bond0 eth0 eth1
五、重啓網絡服務
[root@crushlinux ~]# service network restart
六、測試
用另一臺機器通過ping命令測試
[root@berg ~]# ifconfig eth0 192.168.1.253
[root@berg ~]# ping 192.168.1.254
如果不同對ifcfg-bond0進行排查,如果ping通就可測試雙網卡綁定了,拔掉一根網線,還是通的爲正確。
可將兩塊網卡網線全部拔掉進行測試,接上網線後稍等10~30秒,可繼續ping通。