标签:backup sel run 接口 交换 stop bond0 duplex 输入
一:原理:
linux操作系统下双网卡绑定有七种模式。现在一般的企业都会使用双网卡接入,这样既能添加网络带宽,同时又能做相应的冗余,可以说是好处多多。而一般企业都会使用linux操作系统下自带的网卡绑定模式,当然现在网卡产商也会出一些针对windows操作系统网卡管理软件来做网卡绑定(windows操作系统没有网卡绑定功能 需要第三方支持)。
进入正题,linux有七种网卡绑定模式:
0. round robin;
1.active-backup;
2.load balancing (xor);
3.fault-tolerance (broadcast);
4.lacp;
5.transmit load balancing;
6.adaptive load balancing。
二、试验一:redhat5(mode=1(active-backup):一个网卡处于活动状态 ,一个处于备份状态,所有流量都在主链路上处理。当活动网卡down掉时,启用备份的网卡。)
1、编辑/etc/sysconfig/network-scripts/ifcfg-bond0文件,输入如下指令:
[root@node1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
BOOTPROTO=none
OBBOOT=yes
IPADDR=192.168.100.126
NETMASK=255.255.255.0
TYPE=Ethernet
USERCTL=no
BONDING_OPTS="mode=1 miimon=100"
表示系统在启动时加载bonding模块,对外虚拟网络接口设备为 bond0;miimon=100表示系统每100ms监测一次链路连接状态,如果有一条线路不通就转入另一条线路;mode=1表示fault-tolerance (active-backup)提供冗余功能,工作方式是主备的工作方式,也就是说默认情况下只有一块网卡工作,另一块做备份。 |
2、编辑/etc/sysconfig/network-scripts/ifcfg-eth0文件,输入如下内容:
[root@node1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
MASTER=bond0
SLAVE=yes
3、编辑/etc/sysconfig/network-scripts/ifcfg-eth1文件,输入如下内容:
[root@node1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
MASTER=bond0
SLAVE=yes
4、执行如下指令:
[root@node1 ~]# echo "alias bond0 bonding" >>/etc/modprobe.conf
5、生效bond0
[root@node1 ~]# modprobe bonding
三、试验二:redhat6(mode=1(active-backup):一个网卡处于活动状态 ,一个处于备份状态,所有流量都在主链路上处理。当活动网卡down掉时,启用备份的网卡。)
1、编辑/etc/sysconfig/network-scripts/ifcfg-bond0文件,输入以下内容:
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.100.116
NETMASK=255.255.255.0
GATEWAY=192.168.100.1
TYPE=Ethernet
USERCTL=no
BONDING_OPTS="mode=1 miimon=100 primary=eth0"
2、编辑/etc/sysconfig/network-scripts/ifcfg-eth0文件,输入以下内容:
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
MASTER=bond0
SLAVE=yes
3、编辑/etc/sysconfig/network-scripts/ifcfg-eth1文件,输入以下内容
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
MASTER=bond0
SLAVE=yes
4、执行以下语句:
[root@localhost ~]# #echo "alias bond0 bonding" >>/etc/modprobe.d/dist.conf
[root@localhost ~]# #echo "options bond0 miimon=100 mode=0" >>/etc/modprobe.d/dist.conf
说明: |
5、关闭NetworkManager服务:
[root@localhost ~]# service NetworkManager status
NetworkManager is stopped
[root@localhost ~]# chkconfig NetworkManager off
[root@localhost ~]#
6、重启电脑:
[root@localhost ~]# #init 6
7、ifconfig查看ip:
[root@localhost ~]# ifconfig bond0 Link encap:Ethernet HWaddr 00:50:56:80:2C:53 inet addr:192.168.100.116 Bcast:192.168.100.255 Mask:255.255.255.0 inet6 addr: fe80::250:56ff:fe80:2c53/64 Scope:Link UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1 RX packets:1741 errors:0 dropped:0 overruns:0 frame:0 TX packets:332 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:137206 (133.9 KiB) TX bytes:38181 (37.2 KiB) eth0 Link encap:Ethernet HWaddr 00:50:56:80:2C:53 UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1 RX packets:888 errors:0 dropped:0 overruns:0 frame:0 TX packets:332 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:69751 (68.1 KiB) TX bytes:38181 (37.2 KiB) eth1 Link encap:Ethernet HWaddr 00:50:56:80:2C:53 UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1 RX packets:853 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:67455 (65.8 KiB) TX bytes:0 (0.0 b) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:24827 errors:0 dropped:0 overruns:0 frame:0 TX packets:24827 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:7421150 (7.0 MiB) TX bytes:7421150 (7.0 MiB) virbr0 Link encap:Ethernet HWaddr 52:54:00:82:5F:52 inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) [root@localhost ~]# |
8、查看配置信息
[root@localhost ~]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: eth0 (primary_reselect always)
Currently Active Slave: eth0
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth0
MII Status: up
Speed: 10000 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: 00:50:56:80:2c:53
Slave queue ID: 0
Slave Interface: eth1
MII Status: up
Speed: 10000 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: 00:50:56:80:4c:54
Slave queue ID: 0
标签:backup sel run 接口 交换 stop bond0 duplex 输入
原文地址:http://www.cnblogs.com/wcwen1990/p/6656444.html