注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

红烧鱼

linux & windows management

 
 
 

日志

 
 
关于我
mac

专注IT基础架构设计与运维。 欢迎给我留言,或邮件沟通zjwsk@163.com

网易考拉推荐

Linux NIC bonding & Bridge  

2009-10-13 21:10:46|  分类: Linux |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
网络上介绍Linux下双网卡绑定的方式多是以下方式:
1 vi /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
BOOTPROTO=static
ONBOOT=yes
NETMASK=255.255.252.0
IPADDR=10.106.1.101
GATEWAY=10.106.0.1

2 vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes

3 vi /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes

4 vi /etc/modprobe.conf
alias bond0 bonding
options bonding miimon=100 mode=1

5 vi /etc/rc.local
ifenslave bond0 eth0 eth1
说实在的, 这种模式太傻。

最近在安装XenServer的过程中发现,还有另外一种方法,能一并实现Bridge的功能;将其稍作改写成了个简单脚本,直接粘贴到命令行下执行就可以完成绑定
(特别的地方,仅下面的黄色标注部分,好处是不用在/etc/rc.local中启动网卡绑定的优先顺序,而且不用担心网卡启动时候因物理线路原因导致bonding功能故障):

/etc/modprobe* , 这里不需要设定具体的绑定参数, 只需设定加载网卡绑定模块即可:
echo "alias bond0 bonding" >> /etc/modprobe.conf            # for RHEL5.x
echo "alias bond0 bonding" >> /etc/modprobe.d/anaconda.conf    # for RHEL6.x

cat <<EOF>/etc/sysconfig/network-scripts/ifcfg-eth2
BOOTPROTO=none
DEVICE=eth2
ONBOOT=yes
TYPE=Ethernet
MASTER=bond0
SLAVE=yes
EOF

cat <<EOF>/etc/sysconfig/network-scripts/ifcfg-eth3
BOOTPROTO=none
DEVICE=eth3
ONBOOT=yes
TYPE=Ethernet
MASTER=bond0
SLAVE=yes
EOF

cat <<EOF>/etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
ONBOOT=yes
STARTMODE="onboot"
BONDING_MASTER="yes"
BONDING_OPTS="mode=4 miimon=100"
BONDING_SLAVE0="eth2"
BONDING_SLAVE1="eth3"

IPADDR=10.142.1.6
NETMASK=255.255.255.0
GATEWAY=10.142.1.1
EOF


网卡绑定启用后, 透过下述方式可看到状态
# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)

Bonding Mode: IEEE 802.3ad Dynamic link aggregation
Transmit Hash Policy: layer2 (0)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

802.3ad info
LACP rate: slow
Aggregator selection policy (ad_select): stable
Active Aggregator Info:
    Aggregator ID: 1
    Number of ports: 2
    Actor Key: 17
    Partner Key: 44
    Partner Mac Address: 1c:17:d3:02:53:80

Slave Interface: eth2
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:25:b3:e7:44:2e
Aggregator ID: 1
Slave queue ID: 0

Slave Interface: eth3
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:25:b3:e7:44:30
Aggregator ID: 1
Slave queue ID: 0


---- Linux 网卡绑定涉及技术参考
      在该文中, 有详细描述网卡绑定模式,与交换机设定关系。 摘抄如下:

1. The active-backup, balance-tlb and balance-alb modes:  do not require any specific configuration of the switch.

2. "The 802.3ad mode :
requires that the switch have the appropriate ports configured as an 802.3ad aggregation.
The precise method used to configure this varies from switch to switch, but, for example, a Cisco 3550 series switch requires that the appropriate ports first be grouped together in a single etherchannel instance, then that etherchannel is set to mode ""lacp"" to enable 802.3ad (instead of standard EtherChannel).

3. The balance-rr, balance-xor and broadcast modes :
generally require that the switch have the appropriate ports grouped together.
The nomenclature for such a group differs between switches, it may be called an "etherchannel" (as in the Cisco example, above), a "trunk group" or some other similar variation. For these modes, each switch will also have its own configuration options for the switch's transmit policy to the bond. Typical choices include XOR of either the MAC or IP addresses. The transmit policy of the two peers does not need to match. For these three modes, the bonding mode really selects a transmit policy for an EtherChannel group; all three will interoperate with another EtherChannel group.    


the bible for all things
https://www.kernel.org/doc/Documentation/networking/bonding.txt
  评论这张
 
阅读(1364)| 评论(2)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017