您的位置:首页 > 运维架构 > Linux

linux服务器绑定双网卡(以ubuntu server 10.04)

2013-08-04 16:10 477 查看
Linux双网卡绑定实现就是使用两块网卡虚拟成为一块网卡,这个聚合起来的设备看起来是一个单独的以太网接口设备,通俗点讲就是两块网卡具有相同的IP 地址而并行链接聚合成一个逻辑链路工作。其实这项 技术在Sun和Cisco中早已存在,被称为Trunking和Etherchannel技术,在Linux的2.4.x的内核中也采用这这种技术,被称为bonding。bonding技术的最早应用是在集群——beowulf上,为了提高集群节点间的数据传输而设计的。

下面我们讨论一下bonding 的原理,什么是bonding需要从网卡的混杂(promisc)模式说起。我们知道,在正常情况下,网卡只接收目的硬件地址(MAC Address)是自身Mac的以太网帧,对于别的数据帧都滤掉,以减轻驱动程序的负担。但是网卡也支持另外一种被称为混杂promisc的模式,可以接收网络上所有的帧,比如说tcpdump,就是运行在这个模式下。bonding也运行在这个模式下,而且修改了驱动程序中的mac地址,将两块网卡的 Mac地址改成相同,可以接收特定mac的数据帧。然后把相应的数据帧传送给bond驱动程序处理。

Ubuntu 10.04 server

没安装的话,执行

写道
apt-get install ifenslave-2.6

1、修改网卡配置

Ubuntu的稍微简单一些

写道vim /etc/network/interfaces

auto lo
iface lo inet loopback

auto bond0
iface bond0 inet static
address 192.168.4.132
netmask 255.255.255.0
gateway 192.168.4.1
post-up ifenslave bond0 eth0 eth1
pre-down ifenslave -d bond0 eth0 eth1

2、加载模块

首先执行

写道modprobe bonding
这样就不用重启设备了
当然,配置文件也同样需要添加

写道vim /etc/modules

bonding mode=0 miimon=100

3、重启网卡

执行

写道/etc/init.d/networking restart

完成以后,同样可以查看一下bonding的状态

写道root@132:/etc/network# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 0
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:10:5c:ef:b2:a2
Slave queue ID: 0

Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:10:5c:ef:b2:a3
Slave queue ID: 0
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息