linux 雙網卡綁定~

來源:互聯網
上載者:User

標籤:bsp   網卡   vmware   bootproto   eth0   mac   sys   問題   目錄   

模式bond1: active-backup

模式的特點:一個連接埠處於主狀態 ,一個處於從狀態,所有流量都在主鏈路上處理,從不會有任何流量。當主連接埠down掉時,從連接埠接手主狀態。

先停止NetworkManager
service NetworkManager stop 
chkconfig NetworkManager off   //開機自啟動 關閉


在/etc/sysconfig/network-scripts/目錄下建立ifcfg-bond0檔案,檔案內容如下:

DEVICE=bond0USERCTL=noBOOTPROTO=noneONBOOT=yesIPADDR=192.168.100.17    //你所設定的IPNETMASK=255.255.255.0GATEWAY=192.168.100.1TYPE=UnKnown    //或者Ethernet (若Networkmanager未關閉 就用unknown )BONDING_OPTS="miimon=80 mode=0"   //這一步也可以在下面 /etc/modprobe.d/bonidng.conf 裡面填寫

 


綁定mode為0,是rond-robin模式。
然後分別修改ifcfg-eth0檔案,如下:

DEVICE="eth0"ONBOOT="yes"BOOTPROTO=noneMASTER=bond0SLAVE=yesUSERCTL=no

 


在把ifcfg-eth1檔案修改如下:

DEVICE="eth1"ONBOOT="yes"BOOTPROTO=noneMASTER=bond0SLAVE=yesUSERCTL=no

 

在/etc/modprobe.d/目錄下建立bonding.conf檔案,檔案內容如下:
alias bond0 bonding

---若上一面bond0 配置未填寫 BONDING_OPTS,這裡再另起一行:options bond0 miimon=100 mode=0

 

執行

modprobe  bonding

 

然後重啟網路

service network restart

 

-------如果用遠端連線的話 請使用:modprobe bonding&&service network restart
之後就可以用ifconfig-a看到綁定好的bond0網卡,bond0與eth0,eth1的mac地址均為一樣。
可以同過cat/proc/net/bonding/bond0 此命令查看綁定情況

網卡綁定解除:

刪除ifcfg-bond0,和刪除/etc/modprobe.d/bonding.conf

修改ifcfg-eth0和ifcfg-eth0為綁定之前的樣子

rmmod bonding(很重要)

service network restart

 

注意事項:

1.Warning: the permanent HWaddr of eth0 - 00:0c:29:2d:4a:87 - is still in use by bond0. Set the HWaddr of eth0 to a different address to avoid conflicts.

  an:在網上查了下,很多人都說是VMware workstation的問題,實體機做沒問題。具體原因不太清楚,我上網查的資料:http://blog.csdn.net/robertkun/article/details/16873961,不過我還沒試。
最直接的解決辦法:建議測試的時候不要用ifdown eth0來測試,而是在workstation右下角找到eth0網路介面卡,右鍵中斷連線。

2.為什麼eth0修複後,bond0不返回eth0

3.

[[email protected] network-scripts]# cat ifcfg-bond0 DEVICE=bond0ONBOOT=yes#雙網卡IPIPADDR=192.168.1.100GATEWAY=192.168.1.1NETMASK=255.255.255.0#mode0代表Active-backup policy(主-備份策略)BONDING_OPTS="miimon=80 mode=1"[[email protected] network-scripts]# cat ifcfg-ethcat: ifcfg-eth: No such file or directory[[email protected] network-scripts]# cat ifcfg-eth0DEVICE="eth0"#IPADDR=192.168.1.200#NM_CONTROLLED="yes"ONBOOT="yes"#NETMASK=255.255.255.0#GATEWAY=192.168.1.1MASTER=bond0SLAVE=yesTYPE="Ethernet"UUID="a90ad08d-f6e9-4f34-94e3-690d44454e9e"[[email protected] network-scripts]# cat ifcfg-eth1DEVICE="eth1"#IPADDR=192.168.174.200#NM_CONTROLLED="yes"ONBOOT="yes"MASTER=bond0SLAVE=yes#NETMASK=255.255.255.0#GATEWAY=192.168.1.1#TYPE="Ethernet"#UUID="a90ad08d-f6e9-4f34-94e3-690d44454e9e"

 

感謝:http://blog.csdn.net/yh10169658/article/details/52220582

linux 雙網卡綁定~

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.