当前位置: > RedHat >

RedHat6.5双网卡bonding

时间:2016-10-28 23:09来源:linux.it.net.cn 作者:IT
环境:RHEL 6.5

注意:此处的机器环境是3网卡,我用eth0连ssh的,但是一直掉...

需要关闭NetworkManager,并将其设置为开机不启动(这个玩意儿真烦)
1. 创建bond0文件:
vim /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
ONBOOT=yes
BOOTPROTO=static
TYPE=Ethernet
IPADDR=192.168.115.50
NETMASK=255.255.255.0
2. 修改网卡配置:
vim /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
USERCTL=no

vim /etc/sysconfig/network-scripts/ifcfg-eth2
DEVICE=eth2
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
USERCTL=no
3. 加载bond模块,在配置文件末尾添加参数
vim /etc/modprobe.d/dist.conf
alias bond0 bonding
options bond0 mode=0 miimon=100


    解析:
      

mode 0表示为负载均衡模式,两块网卡都工作

mode 1表示冗余模式,一块是工作,一块冗余

miimon表示系统检查间隔时间,单位是ms,

例如:每100ms检查一次,当发现一条线路不通,就转入另一条



4. 将bond0设置为开机自动加载
vim /etc/rc.local
ifenslave bond0 eth1 eth2

5. reboot ,之后使用ifconfig查看bond0和eht1,eth2两块网卡的MAC地址是否相同
注意不管bond 0 还是bond 1,都是三者相同,因为在交换机的时候需要识别MAC然后发送到对应的MAC上,不相同是不对的,
假如不相同,回去检查NetworkManager是不是关了

来个标准的:
注意

[root@oratest0 ~]# ifconfig
bond0 Link encap:EthernetHWaddr00:0C:29:44:52:23
inet addr:192.168.115.50Bcast:192.168.115.255Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe44:5223/64Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500Metric:1
RX packets:878 errors:0 dropped:0 overruns:0 frame:0
TX packets:349 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:81301(79.3KiB) TX bytes:58143(56.7KiB)
eth0 Link encap:EthernetHWaddr00:0C:29:44:52:19
inet addr:192.168.115.40Bcast:192.168.115.255Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe44:5219/64Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500Metric:1
RX packets:170 errors:0 dropped:0 overruns:0 frame:0
TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:15663(15.2KiB) TX bytes:746(746.0 b)
eth1 Link encap:EthernetHWaddr00:0C:29:44:52:23
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500Metric:1
RX packets:702 errors:0 dropped:0 overruns:0 frame:0
TX packets:175 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:65260(63.7KiB) TX bytes:27907(27.2KiB)
eth2 Link encap:EthernetHWaddr00:0C:29:44:52:23
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500Metric:1
RX packets:176 errors:0 dropped:0 overruns:0 frame:0
TX packets:174 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:16041(15.6KiB) TX bytes:30236(29.5KiB)
lo Link encap:LocalLoopback
inet addr:127.0.0.1Mask:255.0.0.0
inet6 addr:::1/128Scope:Host
UP LOOPBACK RUNNING MTU:16436Metric:1
RX packets:10 errors:0 dropped:0 overruns:0 frame:0
TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:840(840.0 b) TX bytes:840(840.0 b)

6. 查看bond状态,能实时查看两块网卡的工作状态
cat /proc/net/bonding/bond0


(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容