RedHat6.5 bond

环境: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.  
            
    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:Ethernet HWaddr 00:0C:29:44:52:23
  3. inet addr:192.168.115.50 Bcast:192.168.115.255 Mask:255.255.255.0
  4. inet6 addr: fe80::20c:29ff:fe44:5223/64 Scope:Link
  5. UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric: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.3 KiB) TX bytes:58143 (56.7 KiB)
  10. eth0 Link encap:Ethernet HWaddr 00:0C:29:44:52:19
  11. inet addr:192.168.115.40 Bcast:192.168.115.255 Mask:255.255.255.0
  12. inet6 addr: fe80::20c:29ff:fe44:5219/64 Scope:Link
  13. UP BROADCAST RUNNING MULTICAST MTU:1500 Metric: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.2 KiB) TX bytes:746 (746.0 b)
  18. eth1 Link encap:Ethernet HWaddr 00:0C:29:44:52:23
  19. UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric: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.7 KiB) TX bytes:27907 (27.2 KiB)
  24. eth2 Link encap:Ethernet HWaddr 00:0C:29:44:52:23
  25. UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric: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.6 KiB) TX bytes:30236 (29.5 KiB)
  30. lo Link encap:Local Loopback
  31. inet addr:127.0.0.1 Mask:255.0.0.0
  32. inet6 addr: ::1/128 Scope:Host
  33. UP LOOPBACK RUNNING MTU:16436 Metric: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



你可能感兴趣的:(Linux)