首页 > Linux操作系统 > Linux操作系统 > LINUX下双网卡绑定
1.在/etc/sysconfig/network-scripts下vi ifctg-bond0和ifctg-bond1
DEVICE=bond0
NBOOT=yes
BOOTPROTO=static
IPADDR=10.195.228.119
NETMASK=255.255.255.0
BROADCAST=10.195.228.1
TYPE=Ethernet
DEVICE=bond1
NBOOT=yes
BOOTPROTO=static
IPADDR=192.168.0.227
NETMASK=255.255.255.0
BROADCAST=192.168.0.255
TYPE=Ethernet
假设我们要将eth0和eth1绑定,将eth2和eth3绑定.
那我们分别编辑ifcfg-eth0,ifcfg-eth1 和ifcfg-eth2.ifcfg-eth3修改为:
DEVICE=eth0
NBOOT=yes
MASTER=bond0
BOOTPROTO=none
DEVICE=eth1
ONBOOT=yes
MASTER=bond0
BOOTPROTO=none
DEVICE=eth2
ONBOOT=yes
MASTER=bond1
BOOTPROTO=none
DEVICE=eth3
ONBOOT=yes
MASTER=bond1
BOOTPROTO=none
3.修改/etc/modprobe.conf
添加:
alias bond0 bonding
options bond0 miimon=100 mode=1
alias bond1 bonding
options bond1 miimon=100 mode=1
mode指定了bond0的工作模式,常用的是0和1,0表示负载均衡方式,1表示主从方式,miimon是用来进行链路监测的。比如:miimon=100,那么系统每100ms监测一次链路连接状态,如果有一条线路不通就转入另一条线路。
4.修改/etc/rc.d/rc.local,添加内容如下:
ifenslave bond0 eth0 eth1
route add -net 10.195.228.1 netmask 255.255.255.0 bond0
ifenslave bond0 eth0 eth1
route add -net 172.18.0.255 netmask 255.255.255.0 bond1
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/11269677/viewspace-707184/ ,如需转载,请注明出处,否则将追究法律责任。