Red Hat Enterprise Linux AS 下的双网卡绑定


将eth0,eth1绑定为bond0 ,节点内部通信用,使用192.168.1.0网段。
将eth2,eth3绑定为bond1 ,对外服务,使用10.12*.*.0网段。注意将*替换成实际IP地址。

操作系统版本为:Red Hat Enterprise Linux AS release 4 (Nahant Update 7)

<1>
将eth0,eth1绑定为bond0

vi /etc/sysconfig/network-scripts/ifcfg-bond0

DEVICE=bond0
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
IPADDR=192.168.1.2
NETMASK=255.255.255.0
NETWORK=192.168.1.0
BROADCAST=192.168.1.255


vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
MASTER=bond0
SLAVE=yes
注:不要有实际网卡的MAC地址。

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


<2>
将eth2,eth3绑定为bond1

vi /etc/sysconfig/network-scripts/ifcfg-bond1

DEVICE=bond1
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
IPADDR=10.12*.*.61
NETMASK=255.255.255.0
NETWORK=10.12*.*.0
BROADCAST=10.12*.*.255
GATEWAY=10.12*.*.254

vi /etc/sysconfig/network-scripts/ifcfg-eth2
DEVICE=eth2
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
MASTER=bond1
SLAVE=yes


vi /etc/sysconfig/network-scripts/ifcfg-eth3
DEVICE=eth3
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
MASTER=bond1
SLAVE=yes


<3>

添加内核模块:

vi /etc/modprobe.conf
添加
# BONDING
install bond0 /sbin/modprobe bonding -o bond0 mode=1 miimon=100
install bond1 /sbin/modprobe --ignore-install bonding -o bond1 mode=1 miimon=100

note:
mode=0 : load balancing (round-robin)
mode=1 : fault-tolerance (active-backup)


加入启动项
vi /etc/rc.d/rc.local
ifenslave bond0 eth0 eth1
ifenslave bond1 eth2 eth3

启动网卡
ifconfig bond0 192.168.1.2 up
ifenslave bond0 eth0 eth1

ifconfig bond1 10.12*.*.61 up
ifenslave bond1 eth2 eth3


重启网络服务或系统:
service network restart


查看绑定网卡工作状况:
cat /proc/net/bonding/bond0
cat /proc/net/bonding/bond1


************************************************************

linux4.7上,使用如下方式配置,当设置两个或以上bond时,bond网卡的工作模式会有问题,并且第二个bond配置不工作:

vi /etc/modprobe.conf
添加
# BONDING
alias bond1 bonding
options bond1 mode=1 miimon=100

相关内容