歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux教程

RedHat6.5雙網卡bonding

環境: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

更多RedHat相關信息見RedHat 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=10

Copyright © Linux教程網 All Rights Reserved