双网卡绑定
1. 首先在虚拟机上新建两个虚拟网卡,分别为eth0和eth1,然后分别在/etc/sysconfig/network-scripts/ifcfg-eth0 和/etc/sysconfig/network-scripts/ifcfg-eth1 上做些修改。
下面是eth0的修改:
# /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
MASTER=bond0
下面是eth1的修改:
# /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
BOOTPROTO=static
ONBOOT=yes
MASTER=bond0
2. 接着产生一个虚拟网卡bond0,在bond0上配置ip地址以及网关和掩码以及其他信息,下面是bond0的配置内容:
# /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.145.101
NETMASK=255.255.255.0
3. 这个绑定网卡在工作的时候还需要驱动的支持,编辑 /etc/modprobe.conf文件,首先用modprobe bonding 指令查看bond0的模块,为miimon。
# /etc/modprobe.conf
~ alias eth0 pcnet32
alias bond0 bonding
alias scsi_hostadapter mptbase
alias scsi_hostadapter1 mptspi
alias scsi_hostadapter2 ata_piix
alias snd-card-0 snd-ens1371
options snd-card-0 index=0
options bond0 miimon=100 mode=1
options snd-ens1371 index=0
remove snd-ens1371 { /usr/sbin/alsactl store 0 >/dev/null 2>&1 || : ; }; /sbin/modprobe -r --ignore-remove snd-ens1371
alias eth1 pcnet32 (红色为重点)
4. 在开机脚本 /etc/rc.d/rc.local 里面说明谁跟谁绑定在一起,这里是eth0和eth1.
vim /etc/rc.d/rc.local
touch /var/lock/subsys/local
ifenslave bond0 eth0 eth1
5. 用 cat /proc/net/bonding/bond0 来查看网卡绑定状态.
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: 2
Permanent HW addr: 00:0c:29:5b:e0:2b
Slave Interface: eth1
MII Status: down
Link Failure Count: 1
Permanent HW addr: 00:0c:29:5b:e0:35