首頁 > 軟體

RedHat6.5雙網絡卡bonding

2020-06-16 17:30:13

環境:RHEL 6.5

注意:此處的機器環境是3網絡卡,我用eth0連ssh的,但是一直掉...

需要關閉NetworkManager,並將其設定為開機不啟動(這個玩意兒真煩)
1. 建立bond0檔案:
  1. vim /etc/sysconfig/network-scripts/ifcfg-bond0
  2. DEVICE=bond0
  3. ONBOOT=yes
  4. BOOTPROTO=static
  5. TYPE=Ethernet
  6. IPADDR=192.168.115.50
  7. NETMASK=255.255.255.0
2. 修改網絡卡設定:
  1. vim /etc/sysconfig/network-scripts/ifcfg-eth1
  1. DEVICE=eth1
  2. ONBOOT=yes
  3. BOOTPROTO=none
  4. MASTER=bond0
  5. SLAVE=yes
  6. USERCTL=no
 
  1. vim /etc/sysconfig/network-scripts/ifcfg-eth2
  2. DEVICE=eth2
  3. ONBOOT=yes
  4. BOOTPROTO=none
  5. MASTER=bond0
  6. SLAVE=yes
  7. USERCTL=no
3. 載入bond模組,在組態檔末尾新增引數
  1. vim /etc/modprobe.d/dist.conf
    1. alias bond0 bonding
    2. options bond0 mode=0 miimon=100
     
 
    解析:
       
  1. mode 0表示為負載均衡模式,兩塊網絡卡都工作
  2. mode 1表示冗餘模式,一塊是工作,一塊冗餘
  3. miimon表示系統檢查間隔時間,單位是ms,
  4. 例如:每100ms檢查一次,當發現一條線路不通,就轉入另一條
 
 
4. 將bond0設定為開機自動載入
  1. vim /etc/rc.local
  2. ifenslave bond0 eth1 eth2
 
5. reboot ,之後使用ifconfig檢視bond0和eht1,eth2兩塊網絡卡的MAC地址是否相同
注意不管bond 0 還是bond 1,都是三者相同,因為在交換機的時候需要識別MAC然後傳送到對應的MAC上,不相同是不對的,
假如不相同,回去檢查NetworkManager是不是關了
 
來個標準的:
注意
 
  1. [root@oratest0 ~]# ifconfig
  2. bond0 Link encap:EthernetHWaddr00:0C:29:44:52:23
  3. inet addr:192.168.115.50Bcast:192.168.115.255Mask:255.255.255.0
  4. inet6 addr: fe80::20c:29ff:fe44:5223/64Scope:Link
  5. UP BROADCAST RUNNING MASTER MULTICAST MTU:1500Metric:1
  6. RX packets:878 errors:0 dropped:0 overruns:0 frame:0
  7. TX packets:349 errors:0 dropped:0 overruns:0 carrier:0
  8. collisions:0 txqueuelen:0
  9. RX bytes:81301(79.3KiB) TX bytes:58143(56.7KiB)
  10. eth0 Link encap:EthernetHWaddr00:0C:29:44:52:19
  11. inet addr:192.168.115.40Bcast:192.168.115.255Mask:255.255.255.0
  12. inet6 addr: fe80::20c:29ff:fe44:5219/64Scope:Link
  13. UP BROADCAST RUNNING MULTICAST MTU:1500Metric:1
  14. RX packets:170 errors:0 dropped:0 overruns:0 frame:0
  15. TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
  16. collisions:0 txqueuelen:1000
  17. RX bytes:15663(15.2KiB) TX bytes:746(746.0 b)
  18. eth1 Link encap:EthernetHWaddr00:0C:29:44:52:23
  19. UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500Metric:1
  20. RX packets:702 errors:0 dropped:0 overruns:0 frame:0
  21. TX packets:175 errors:0 dropped:0 overruns:0 carrier:0
  22. collisions:0 txqueuelen:1000
  23. RX bytes:65260(63.7KiB) TX bytes:27907(27.2KiB)
  24. eth2 Link encap:EthernetHWaddr00:0C:29:44:52:23
  25. UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500Metric:1
  26. RX packets:176 errors:0 dropped:0 overruns:0 frame:0
  27. TX packets:174 errors:0 dropped:0 overruns:0 carrier:0
  28. collisions:0 txqueuelen:1000
  29. RX bytes:16041(15.6KiB) TX bytes:30236(29.5KiB)
  30. lo Link encap:LocalLoopback
  31. inet addr:127.0.0.1Mask:255.0.0.0
  32. inet6 addr:::1/128Scope:Host
  33. UP LOOPBACK RUNNING MTU:16436Metric:1
  34. RX packets:10 errors:0 dropped:0 overruns:0 frame:0
  35. TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
  36. collisions:0 txqueuelen:0
  37. RX bytes:840(840.0 b) TX bytes:840(840.0 b)
 
6. 檢視bond狀態,能實時檢視兩塊網絡卡的工作狀態
  1. cat /proc/net/bonding/bond0

IT145.com E-mail:sddin#qq.com