不同linux下两网卡绑定方法

记得原来在做性能测试时,为了提高网络吞吐率。必须将两个网卡绑定一起工作。绑定方法如下:

一、CentOS 配置

 

1、编辑虚拟网络接口配置文件,指定网卡IP:

# vi /etc/sysconfig/network-scripts/ifcfg-bond0
或者下面命令
# cp /etc/sysconfig/network-scripts/ifcfg-eth0 ifcfg-bond0

2、修改bond0

#vi ifcfg-bond0

将第一行改成 DEVICE=bond0:
如下: 
DEVICE=bond0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.61.72
NETMASK=255.255.255.240
#BROADCAST=192.168.61.79
#GATEWAY=192.168.61.77
这里要注意,不要指定单个网卡的IP 地址、子网掩码或网卡 ID。将上述信息指定到虚拟适配器(bonding)中即可。
# cat ifcfg-eth0 
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
HWADDR=00:15:17:CC:FC:35
MASTER=bond0
SLAVE=yes
# cat ifcfg-eth1 
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
HWADDR=00:15:17:CC:FC:34
MASTER=bond0
SLAVE=yes

3、  # vi /etc/modules.conf

编辑 /etc/modprobe.conf或者/etc/modules.conf文件,加入如下两行内容,以使系统在启动时加载bonding模块,对外虚拟网络接口设备为 bond0.加入下列两行:

alias bond0 bonding
options bond0 miimon=100 mode=1

如果在5.3中使用/etc/modules.conf代替/etc/modprobe.conf文件,会在系统出现如下错误:

bonding device bond0 does not seem to be present,delaying initialization.

4、修改rc.local文件

# vi /etc/rc.d/rc.local

加入两行,加在启动自运行文件里面

ifenslave bond0 eth0 eth1
route add -net 172.31.3.254 netmask 255.255.255.0 bond0        #如果需要的话加路由,不需要不用加

到这时已经配置完毕重新启动机器. 重启会看见以下信息就表示配置成功了

Bringing up interface bond0 OK
Bringing up interface eth0 OK
Bringing up interface eth1 OK

二、Ubuntu 配置

1、修改interfaces文件

 

root@8005:/etc/network# vi interfaces
# The loopback network interface
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
 
# The loopback network interface
auto lo
iface lo inet loopback
 
auto bond0
iface bond0 inet static
address 10.50.210.73
netmask 255.255.255.0
gateway 10.50.210.1
slaves eth0 eth1 eth2 eth3
#bond-mode balance-xor
#bond-miimon 100
#bond-primary eth0 eth1 eth2 eth3
#bond-xmit_hash_policy layer3+4
up   /sbin/ifenslave    bond0 eth0 eth1 eth2 eth3
down /sbin/ifenslave -d bond0 eth0 eth1 eth2 eth3
 
#SkyOne
# The primary network interface
#auto eth0
#iface eth0 inet dhcp
 
# The secondary network interface
#auto eth1
#iface eth1 inet dhcp
 
#auto br0
#iface br0 inet dhcp
#       bridge_ports eth0
#       bridge_fd 9
#       bridge_hello 2
#       bridge_maxage 12
#       bridge_stp off

 

2、修改modprobe

 

root@8005:/etc/modprobe.d# pwd
/etc/modprobe.d
 
root@8005:/etc/modprobe.d# vi bonding.conf
 
alias bond0 bonding
options bond0 mode=balance-xor miimon=100 xmit_hash_policy=layer3+4

 

 查看bond状态:

 cat /proc/net/bonding/bond0

 

三、交换机配置

交换机配置:

  1active-backupbalance-tlb  balance-alb 模式不需要对交换机做任何的配置。

mode 15时,不需要对交换机做配置

  2balance-rrbalance-xorbroadcast模式通常需要交换机对应的端口被分组在一起

 

:cisco 3750的配置

  (config)#interface channel-group 1

(config-if)#switch access vlan42        

(config-if)#interface gigabitethernet 1/1

(config-if)# switchport

(config-if)#no ip address

(config-if)#channel-group 1 mod on

(config-if)#no shutdown

(config-)#interface gigabitethernet 1/2

(config-if)#no switchport

(config-if)#interface gigabitethernet 1/1

(config-if)# switchport

(config-if)#no ip address

(config-if)#channel-group 1 mod on

(config-if)#no shutdown

(config-)#interface gigabitethernet 1/2

(config-if)# switchport

 

不同交换机默认是no switch模式需要更改,switch模式port-channel必须和端口保持一致

 

转载于:https://www.cnblogs.com/landhu/p/4991899.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值