Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2129256
  • 博文数量: 229
  • 博客积分: 7217
  • 博客等级: 上校
  • 技术积分: 3224
  • 用 户 组: 普通用户
  • 注册时间: 2009-02-19 17:23
个人简介

个人主页https://xugaoxiang.com,微信公众号: Dev_Club 或者搜索 程序员Club

文章分类

全部博文(229)

文章存档

2017年(1)

2016年(20)

2015年(23)

2013年(1)

2012年(23)

2011年(68)

2010年(62)

2009年(31)

分类: LINUX

2009-06-24 10:42:07

OS:centos 5
bonding的作用是把多块网卡虚拟成一块网卡,使用一个IP地址,一个MAC地址。一般的发行版内核都支持bonding,如果碰到不支持的,重编下内核使其支持就可以了。

cd /etc/sysconfig/network-scripts
cp ifcfg-eth0 ifcfg-bond0


vi ifcfg-bond0
# Broadcom NetXtreme II BCM5708 Gigabit Ethernet      
DEVICE=bond0      
BROADCAST=192.168.0.255       HWADDR=00:22:19:CD:CD:44      
IPADDR=192.168.0.251      
NETMASK=255.255.255.0      
ONBOOT=yes      
GATEWAY=192.168.0.1      
TYPE=Ethernet

cat ifcfg-eth0
# Broadcom NetXtreme II BCM5708 Gigabit Ethernet       DEVICE=eth0      
HWADDR=00:1A:64:64:6C:C8       NETMASK=255.255.255.0      
ONBOOT=yes      
TYPE=Ethernet

cat ifcfg-eth1
      
# Broadcom NetXtreme II BCM5708 Gigabit Ethernet       DEVICE=eth1      
HWADDR=00:1A:64:64:6C:CA       NETMASK=255.255.255.0      
ONBOOT=yes      
TYPE=Ethernet

cp /etc/modprobe.conf /etc/modprobe.conf.bak

vi /etc/modprobe.conf
alias bond0 bonding      
options bond0 miimon=100 mode=1   
#增加以上这两句      
alias scsi_hostadapter mptbase      
alias scsi_hostadapter1 mptscsih      
options lnet networks=tcp0

开机启动bonding
vi /etc/rc.local

modprobe bonding
ifenslave bond0 eth0 eth1

#在主备模式下工作,会按照先后顺序提供网卡服务,这里是eth0然后是eth1,如果其中有一块网卡失效,网络也不会中断,有点像RAID1的功能。

reboot


ifconfig

bond0     Link encap:Ethernet  HWaddr 00:1A:64:64:6C:C8  
          inet addr:192.168.0.251  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::21a:64ff:fe64:6cc8/64 Scope:Link
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
          RX packets:17066 errors:0 dropped:0 overruns:0 frame:0
          TX packets:105 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1118781 (1.0 MiB)  TX bytes:21938 (21.4 KiB)

eth0      Link encap:Ethernet  HWaddr 00:1A:64:64:6C:C8  
          inet6 addr: fe80::21a:64ff:fe64:6cc8/64 Scope:Link
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:8672 errors:0 dropped:0 overruns:0 frame:0
          TX packets:89 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:568833 (555.5 KiB)  TX bytes:17518 (17.1 KiB)
          Interrupt:3 Memory:ce000000-ce012100

eth1      Link encap:Ethernet  HWaddr 00:1A:64:64:6C:C8  
          inet6 addr: fe80::21a:64ff:fe64:6cc8/64 Scope:Link
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:8394 errors:0 dropped:0 overruns:0 frame:0
          TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:549948 (537.0 KiB)  TX bytes:4420 (4.3 KiB)
          Interrupt:10 Memory:ca000000-ca012100

从上面的输出可以看到,bond0、eth0、eth1的HWaddr都是00:1A:64:64:6C:C8

查看bonding的状态
cat /proc/net/bonding/bond0

Ethernet Channel Bonding Driver: v3.1.2 (January 20, 2007)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
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
Link Failure Count: 0
Permanent HW addr: 00:1a:64:64:6c:c8

Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:1a:64:64:6c:ca
阅读(1543) | 评论(0) | 转发(0) |
0

上一篇:linux启动过程

下一篇:MKV文件格式

给主人留下些什么吧!~~