雙網卡綁定交換機配置?
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。
第一種:bond0:round robin
標準:round-robin policy: Transmit packets in sequential order from the first available slave through the last. This mode provides load balancing and fault tolerance.
特點:(1)所有鏈路處于負載均衡狀態,輪詢方式往每條鏈路發送報文,基于per packet方式發送。服務上ping 一個相同地址:1.1.1.1 雙網卡的兩個網卡都有流量發出。負載到兩條鏈路上,說明是基于per packet方式 ,進行輪詢發送。(2)這模式的特點增加了帶寬,同時支持容錯能力,當有鏈路出問題,會把流量切換到正常的鏈路上。
實際綁定結果:
cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)
Bonding Mode: load balancing (round-robin) -----RR的模式
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: 74:ea:3a:6a:54:e3
Slave Interface: eth1
MII Status: up
Link Failure Count: 0
應用拓撲:交換機端需要配置聚合口,cisco叫port channel
第二種:bond1:active-backup
標準文檔定義:Active-backup policy: Only one slave in the bond is active. A different slave becomes active if, and only if, the active slave fails. The bond’s MAC address is externally visible on only one port (network adapter) to avoid confusing the switch. This mode provides fault tolerance. The primary option affects the behavior of this mode.
模式的特點:一個端口處于主狀態 ,一個處于從狀態,所有流量都在主鏈路上處理,從不會有任何流量。當主端口down掉時,從端口接手主狀態。
實際綁定結果:
root@1:~# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)
Bonding Mode: fault-tolerance (active-backup) —–backup模式
Primary Slave: None
Currently Active Slave: eth0
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: 74:ea:3a:6a:54:e3
Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: d8:5d:4c:71:f9:94
應用拓撲:這種模式接入不需要交換機端支持,隨便怎么接入都行。
第三種:bond2:load balancing (xor)
標準文檔描述:XOR policy: Transmit based on [(source MAC address XOR'd with destination MAC address) modulo slave count]. This selects the same slave for each destination MAC address. This mode provides load balancing and fault tolerance.
特點:該模式將限定流量,以保證到達特定對端的流量總是從同一個接口上發出。既然目的地是通過MAC地址來決定的,因此該模式在“本地”網絡配置下可以工作得很好。如果所有流量是通過單個路由器(比如 “網關”型網絡配置,只有一個網關時,源和目標mac都固定了,那么這個算法算出的線路就一直是同一條,那么這種模式就沒有多少意義了。),那該模式就不是最好的選擇。和balance-rr一樣,交換機端口需要能配置為“port channel”。這模式是通過源和目標mac做hash因子來做xor算法來選路的。
實際綁定結果:
[root@localhost ~]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.0.3 (March 23, 2006)
Bonding Mode: load balancing (xor) ——配置為xor模式
Transmit Hash Policy: layer2 (0)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:d0:f8:40:f1:a0
Slave Interface: eth2
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:d0:f8:00:0c:0c
應用拓撲:同bond0一樣的應用模型。這個模式也需要交換機配置聚合口。
第四種:bond3:fault-tolerance (broadcast)
標準文檔定義:Broadcast policy: transmits everything on all slave interfaces. This mode provides fault tolerance.
特點:這種模式的特點是一個報文會復制兩份往bond下的兩個接口分別發送出去,當有對端交換機失效,我們感覺不到任何downtime,但此法過于浪費資源;不過這種模式有很好的容錯機制。此模式適用于金融行業,因為他們需要高可靠性的網絡,不允許出現任何問題。
實際綁定結果:
root@ubuntu12:~/ram# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)
Bonding Mode: fault-tolerance (broadcast) ——- fault-tolerance 模式
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: 74:ea:3a:6a:54:e3
Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: d8:5d:4c:71:f9: