Linux下雙網卡綁定bond0【轉】

來源:互聯網
上載者:User

標籤:ima   作業系統   bonding   src   工作   使用   啟動   get   roc   

一:原理:

linux作業系統下雙網卡綁定有七種模式。現在一般的企業都會使用雙網卡接入,這樣既能添加網路頻寬,同時又能做相應的冗餘,可以說是好處多多。而一般企業都會使用linux作業系統下內建的網卡繫結模式,當然現在網卡產商也會出一些針對windows作業系統網卡管理軟體來做網卡綁定(windows作業系統沒有網卡綁定功能 需要第三方支援)。進入正題,linux有七種網卡繫結模式:0. round robin,1.active-backup,2.load balancing (xor),  3.fault-tolerance (broadcast), 4.lacp,  5.transmit load balancing, 6.adaptive load balancing。

二:案例一mode=1(active-backup):一個網卡處於活動狀態 ,一個處於備份狀態,所有流量都在主鏈路上處理。當活動網卡down掉時,啟用備份的網卡。

1:[[email protected] ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0           #編輯該裝置eth0

[[email protected] ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth1            #編輯該裝置eth1

2:[[email protected] ~]# cd /etc/sysconfig/network-scripts/

[[email protected] network-scripts]# cp ifcfg-eth0  ifcfg-bond0        #產生一個bond0的虛擬網卡

[[email protected] network-scripts]# vim ifcfg-bond0        #編輯該網卡內容

3:[[email protected] network-scripts]# vim /etc/modprobe.conf       #編輯該設定檔

中1表示系統在啟動時載入bonding模組,對外虛擬網路介面裝置為 bond0;miimon=100表示系統每100ms監測一次鏈路串連狀態,如果有一條線路不通就轉入另一條線

路;mode=1表示fault-tolerance (active-backup)提供冗餘功能,工作方式是主備的工作方式,也就是說預設情況下只有一塊網卡工作,另一塊做備份。

4:[[email protected] network-scripts]# vim /etc/rc.local        #編輯該開機指令碼,將eth0和eth1網卡進行綁定

5:[[email protected] network-scripts]# init 6       #重啟,bond0啟動成功

[[email protected] ~]# ifconfig      #查看網卡資訊,在此處三塊網卡的mac地址是一樣的

[[email protected] ~]#vim /proc/net/bonding/bond0      #查看模式及網卡資訊。實際mac地址是不一樣的

測試:

6:Xshell:\> ping 192.168.101.50  –t      #一直測試網路的連通性查看結果

斷掉eth0網卡後顯示結果

將網卡eth0斷掉後,系統使用備份網卡eth1,此時eth1處於活動狀態

案例二:mode=0(round robin):所有鏈路處於負載平衡狀態,這模式的特點增加了頻寬,同時支援容錯能力。

1:在案例一的基礎上,只需要修改/etc/modprobe.conf 設定檔:

2:vim /proc/net/bonding/bond0        #查看使用的模式及網卡資訊,

 

測試:mode=0:

3:Xshell:\> ping 192.168.101.50 –t #一直測試網路的連通性查看結果

將網卡eth1斷掉後,系統依然可以ping通

 

本文出自 “. . .” 部落格,請務必保留此出處http://5503845.blog.51cto.com/5493845/96258

Linux下雙網卡綁定bond0【轉】

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.