共計 1716 個字符,預計需要花費 5 分鐘才能閱讀完成。
丸趣 TV 小編給大家分享一下 Debian 雙網卡 bond 的示例發信息,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
1. 安裝 ifenslave
ifenslave 的作用是網卡的負載均衡
# apt-get install ifenslave
2. 修改 /etc/network/interface
代碼如下:
{root@b01 359 ~}
# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
auto A quot;tagshow(bond return false; href= /tag/bond/ bond /A 0
iface bond0 inet static
address 192.168.1.5
netmask 255.255.255.0
gateway 192.168.1.1
up ifenslave bond0 eth0 eth2
down ifenslave -d bond0 eth0 eth2
dns-nameservers 8.8.8.8
iface eth0 inet static
iface eth2 inet static
3. 加載 bonding 模塊(這塊費了大部分時間)
代碼如下:
# cat /etc/modprobe.d/aliases-bond
install bond0 /sbin/modprobe bonding miimon=100 mode=0
bond 的 mode 一共有七種:
代碼如下:
0:(balance-rr) Round-robin policy:(平衡掄循環策略):傳輸數據包順序是依次傳輸,直到最后一個傳輸完畢,此模式提供負載平衡和容錯能力。
1:(active-backup) Active-backup policy:(主 - 備份策略):只有一個設備處于活動狀態。一個宕掉另一個馬上由備份轉換為主設備。mac 地址是外部可見得。此模式提供了容錯能力。
2:(balance-xor) XOR policy:(廣播策略):將所有數據包傳輸給所有接口。此模式提供了容錯能力。
3:(balance-xor) XOR policy:(平衡策略):傳輸根據原地址布爾值選擇傳輸設備。此模式提供負載平衡和容錯能力。
4:(802.3ad) IEEE 802.3ad Dynamic link aggregation.IEEE 802.3ad 動態鏈接聚合:創建共享相同的速度和雙工設置的聚合組。
5:(balance-tlb) Adaptive transmit load balancing(適配器傳輸負載均衡): 沒有特殊策略,第一個設備傳不通就用另一個設備接管第一個設備正在處理的 mac 地址,幫助上一個傳。
6:(balance-alb) Adaptive load balancing:(適配器傳輸負載均衡):大致意思是包括 mode5,bonding 驅動程序截獲 ARP 在本地系統發送出的請求,用其中之一的硬件地址覆蓋從屬設備的原地址。就像是在服務器上不同的人使用不同的硬件地址一樣
一個小技巧:
為了防止修改網卡配置或其他配置錯誤導致不能連接服務器,寫一個 crontab, 將正確的網卡配置文件恢復后重新 network restart 或者
重啟機器 (iptable 等類似風險操作也可以這樣來處理)
代碼如下:
{root@b01 361 ~}
# crontab -l
# m h dom mon dow command
#20 * * * * cp -pr /etc/network/interfaces.org /etc/network/interfaces
#21 * * * * /sbin/init 6
以上是“Debian 雙網卡 bond 的示例發信息”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注丸趣 TV 行業資訊頻道!