您的位置:首页 > 运维架构 > Linux

CentOS 5/6/7网卡绑定方案

2017-01-11 20:34 337 查看
网卡绑定方法:

Centos/RHEL5/6 —— Bond方案

1.    网卡配置

#cd/etc/sysconfig/network-script/

#vi ifcfg-eth0

DEVICE=eth0

ONBOOT=yes

BOOTPROTO=none

MASTER=bond0

SLAVE=yes

 

 

#vi ifcfg-eth1

DEVICE=eth1

ONBOOT=yes

BOOTPROTO=none

MASTER=bond0

SLAVE=yes

 

 

#vi ifcfg-bond0

DEVICE=bond0

ONBOOT=yes

BOOTPROTO=static

IPADDR=X.X.X.X

NETMASK=X.X.X.X

GATEWAY=X.X.XX

2.    模块加载配置

a.    Rhel/Centos6.x

#vi/etc/modprobe.d/bond.conf

alias bond1 bonding

options bond0miimon=100 mode=0

(配置模式这里配置为mode=0负载均衡模式0,mode参数为模式类型,具体请参考相关模式资料。miimon为监听时间,我设置100为0.1毫秒)

b.   Rhel/Centos5.x

#vi /etc/modprobe.conf

加入以下两行内容

alias bond1 bonding

options bond0miimon=100 mode=0

 

3.    重启并测试

a.    重启系统

b.   用另外两台机器ping该机器

Ifconfig中可以看到eth0和eth1中流量有变化则说明OK

Centos/RHEL  7 —— Team方案

1.    Ifcfg-ethx配置

[root@QD-254-28network-scripts]# cat ifcfg-eth0

NAME=eth0

DEVICE=eth0

DEVICETYPE=TeamPort

ONBOOT=yes

TEAM_MASTER=team0

2.    Ifcfg-team0配置

[root@QD-254-28 network-scripts]# catifcfg-team0

NAME=team0

DEVICE=team0

DEVICETYPE=Team

ONBOOT=yes

BOOTPROTO=none

IPADDR=10.32.254.28

PREFIX=24

    TEAM_CONFIG="{\"runner\":{\"name\": \"lacp\", \"active\": true,\"fast_rate\": true, \"tx_hash\": [\"eth\",\"ipv4\", \"ipv6\"]}, \"link_watch\": {\"name\":\"ethtool\"}, \"ports\":{\"eth0\": {}, \"eth2\":{}}}"

 

3.    Ifcfg-team1配置

NAME=team1

DEVICE=team1

DEVICETYPE=Team

BOOTPROTO=none

#UUID=dd9fd5f2-1e36-4266-96fd-1de7eea23301

ONBOOT=yes

TEAM_CONFIG="{\"runner\":{\"name\": \"lacp\", \"active\": true,\"fast_rate\": true, \"tx_hash\": [\"eth\",\"ipv4\", \"ipv6\"]}, \"link_watch\": {\"name\":\"ethtool\"}, \"ports\":{\"eth1\": {},\"eth3\": {}}}"

IPADDR=119.167.254.28

PREFIX=24

GATEWAY=119.167.254.254

4.    route-team0配置

ADDRESS0=10.0.0.0

NETMASK0=255.0.0.0

GATEWAY0=10.32.254.254

METRIC0=0

 注意点:

1.    在centos7中必须启用NetworkManager

2.    不要在配置文件中加上DEFROUTE的设置,很坑

3.    Centos7内网路由需要以route-team0文件的形式存在,加在rc.local中无效
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: