vmware workstation 12
常規真機環境下,給網卡做bond配置如下(假設是bond0):
1、ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
MASTER=bond0
BOOTPROTO=none
SLAVE=yes
2、ifcfg-eth1
DEVICE=eth1
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
ONBOOT=yes
3、ifcfg-bond0
DEVICE=bond0
BOOTPROTO=static
IPADDR=172.16.3.22
NETMASK=255.255.248.0
ONBOOT=yes
BROADCAST=10.1.7.255
4、/etc/modprobe.conf
原有文件內容後,追加如下配置:
alias bond0 bonding
options bond0 miimon=100 mode=1
配置解釋: miimon=100 ,系統每100ms 監測一次鏈路連接狀態,mode=1,表示網卡eth0,eth1採用熱備模式(如果mode=1,則表示eth0和eth1採用負載均衡模式)
5、/etc/rc.local
原有文件內容後,追加如下配置:
ifenslave bond0 eth0 eth1
配置解釋: 指定熱備模式下eth0和eth1網卡的工作順序
6、重啓服務器
與真機環境有所不同,vmware虛擬機下給linux系統做bond0網卡配置,照這樣做完後,測試發現down掉eth0後,bond0網卡ping不通,無法起到網卡備份效果。
查了下資料,發現需要在bond0配置文件中增加一項參數配置,即修改後的bond0網卡配置文件如下:
DEVICE=bond0
BOOTPROTO=static
IPADDR=172.16.3.22
NETMASK=255.255.248.0
ONBOOT=yes
BROADCAST=10.1.7.255
BONDING_OPTS="fail_over_mac=1"
配置解釋: 默認fail_over_mac=0,當發生錯誤時,只改slave的mac不改bond;fail_over_mac=1時,只改bond不改slave。
改完後,service network restart重啓下網卡配置,down掉eth0,bond0就可以通了