2015年11月13日 星期五

centos雙網卡綁定技術


以下資料取自http://codex.wiki/post/164939-821


在/etc/sysconfig/network-scripts/目錄下建立ifcfg-bond0文件,文件內容如下:

DEVICE=bond0 

USERCTL=no

BOOTPROTO=none

ONBOOT=yes

IPADDR=192.168.100.17

NETMASK=255.255.255.0

GATEWAY=192.168.100.1

TYPE=UnKnown

BONDING_OPTS="miimon=80 mode=0"

綁定mode為0,是rond-robin模式。

然後分別修改ifcfg-eth0文件,如下:

DEVICE="eth0"

#HWADDR="00:0D:60:9A:7B:0A"

ONBOOT="yes"

BOOTPROTO=none

MASTER=bond0

SLAVE=yes

USERCTL=no

在把ifcfg-eth1文件修改如下:

DEVICE="eth1"

#HWADDR="00:0D:60:9A:7B:0B"

ONBOOT="yes"

BOOTPROTO=none

MASTER=bond0

SLAVE=yes

USERCTL=no

在/etc/modprobe.d/目錄下建立bonding.conf文件,文件內容如下:

alias bond0 bonding

然後重啟網路service network restart

之後就可以用ifconfig -a看到綁定好的bond0網卡,bond0與eth0,eth1的mac地址均為一樣。

可以同過cat /proc/net/bonding/bond0 此命令查看綁定情況