使用双网卡虚拟为一块网卡:
服务器版本:
[root@kel ~]# lsb_release -a
LSB Version: :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 5.4 (Tikanga)
Release: 5.4
Codename: Tikanga
内核:
[root@kel ~]# uname -a
Linux kel 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
1、 配置虚拟网卡
网卡的配置文件均在此路径下:
/etc/sysconfig/network-scripts
[root@kel network-scripts]# cp ifcfg-eth0 ifcfg-bond0
修改其中的内容为:
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=bond0
BOOTPROTO=static
IPADDR=192.168.1.110
GATEWAY=192.168.1.2
DHCPCLASS=
ONBOOT=yes
2、 配置eth0
[root@kel network-scripts]# vi ifcfg-eth0
修改其中的内容为:
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=none
DHCPCLASS=
HWADDR=00:0C:29:9C:95:9E
ONBOOT=yes
MASTER=bond0 --主要要修改的
SLAVE=yes <span style="font-family: Arial, Helvetica, sans-serif;">--主要要修改的</span>
USERCTL=yes
3、 配置eth1
[root@kel network-scripts]# vi ifcfg-eth1
修改其中的内容为:
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
HWADDR=00:0c:29:9c:95:a8
MASTER=bond0 --主要要修改的
SLAVE=yes --主要要修改的
USERCTL=yes
4、 修改模块配置文件
在模块的配置文件/etc/modprobe.conf中添加如下内容:
alias bond0 bonding
options bond0 miimon=100 mode=1
mode指定了bond0的工作模式,常用的是0和1,0表示负载均衡方式,1表示主从方式
在Description:
Red Hat Enterprise Linux Server release 6.2 (Santiago)版本中,配置文件发生了改变,配置文件地址如下:
@kelB1:/root# cat /etc/modprobe.d/bonding.conf
alias bond0 bonding
options bond0 miimon=100 mode=1
5、 开机启动脚本
在 /etc/rc.d/rc.local里添加如下内容:
ifenslave bond0 eth0 eth1
6、 重启网络
[root@kel network-scripts]# service network restart
Shutting down interface bond0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface bond0: [ OK ]
7、 查看结果
[root@kel network-scripts]# ifconfig
bond0 Link encap:Ethernet HWaddr 00:0C:29:9C:95:9E
inet addr:192.168.1.110 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe9c:959e/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:2313 errors:0 dropped:0 overruns:0 frame:0
TX packets:1445 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:205869 (201.0 KiB) TX bytes:215368 (210.3 KiB) eth0 Link encap:Ethernet HWaddr 00:0C:29:9C:95:9E
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:1888 errors:0 dropped:0 overruns:0 frame:0
TX packets:1403 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:165523 (161.6 KiB) TX bytes:207440 (202.5 KiB)
Base address:0x2000 Memory:d8940000-d8960000 eth1 Link encap:Ethernet HWaddr 00:0C:29:9C:95:9E
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:429 errors:0 dropped:0 overruns:0 frame:0
TX packets:51 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:40586 (39.6 KiB) TX bytes:9330 (9.1 KiB)
Base address:0x2080 Memory:d8960000-d8980000
具体测试的时候,可以拔掉网线,然后ping IP地址即可