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

一、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= mode=

如果在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@:/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(). # 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
#bond-primary eth0 eth1 eth2 eth3
#bond-xmit_hash_policy layer3+
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
# bridge_hello
# bridge_maxage
# bridge_stp off

2、修改modprobe

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

查看bond状态:

cat /proc/net/bonding/bond0

三、交换机配置

交换机配置:

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

即mode 为1,5,6 时,不需要对交换机做配置

2、balance-rr、balance-xor和broadcast模式通常需要交换机对应的端口被分组在一起

例: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必须和端口保持一致

不同linux下两网卡绑定方法的更多相关文章

  1. Linux下双网卡绑定(bonding技术)

    Linux网卡绑定探析   2013-08-20 15:39:31 现在很多服务器都自带双千兆网口,利用网卡绑定既能增加网络带宽,同时又能做相应的冗余,目前应用于很多的场景.linux操作系统下自带的 ...

  2. Linux下双网卡绑定bond0

    一:原理: linux操作系统下双网卡绑定有七种模式.现在一般的企业都会使用双网卡接入,这样既能添加网络带宽,同时又能做相应的冗余,可以说是好处多多.而一般企业都会使用linux操作系统下自带的网卡绑 ...

  3. Linux下双网卡绑定bond0【转】

    一:原理: linux操作系统下双网卡绑定有七种模式.现在一般的企业都会使用双网卡接入,这样既能添加网络带宽,同时又能做相应的冗余,可以说是好处多多.而一般企业都会使用linux操作系统下自带的网卡绑 ...

  4. 深度分析Linux下双网卡绑定七种模式 多网卡的7种bond模式原理

    http://blog.csdn.net/abc_ii/article/details/9991845多网卡的7种bond模式原理 Linux网卡绑定mode共有七种(~) bond0.bond1.b ...

  5. Linux下多网卡绑定bond0及模式

    Linux 多网卡绑定 网卡绑定mode共有七种(0~6) bond0.bond1.bond2.bond3.bond4.bond5.bond6 常用的有三种 mode=0:平衡负载模式,有自动备援,但 ...

  6. Linux下双网卡绑定bond配置实例详解

    本文源自:http://blog.itpub.net/31015730/viewspace-2150185/ 一.什么是bond? 网卡bond是通过多张网卡绑定为一个逻辑网卡,实现本地网卡冗余,带宽 ...

  7. (转)深度分析Linux下双网卡绑定七种模式

    现在一般的企业都会 使用双网卡接入,这样既能添加网络带宽,同时又能做相应的冗余,可以说是好处多多.而一般企业都会使用linux操作系统下自带的网卡绑定模式,当然现在 网卡产商也会出一些针对window ...

  8. 深度分析Linux下双网卡绑定七种模式

    现在一般的企业都会使用双网卡接入,这样既能添加网络带宽,同时又能做相应的冗余,可以说是好处多多.而一般企业都会使用linux操作系统下自带的网卡绑定模式,当然现在网卡产商也会出一些针对windows操 ...

  9. Linux下多网卡绑定bond及模式介绍

    [介绍] 网卡bond一般主要用于网络吞吐量很大,以及对于网络稳定性要求较高的场景. 主要是通过将多个物理网卡绑定到一个逻辑网卡上,实现了本地网卡的冗余,带宽扩容以及负载均衡. Linux下一共有七种 ...

随机推荐

  1. rails rake 版本问题

    rails rake 版本问题 通常情况下,如果我们电脑上同时装了不同版本的rake时,运行rake命令时会出错,如: rake db:migrate rake aborted! You have a ...

  2. GridView截取某一列字符串的长度

    Gridview中,如果你的某一列字符串的长度过长,不做处理的话.那么将显示的奇丑无比, 可以采取设置样式,将其显示为定长,可以在点击查看的时候,在另一个页面对其进行显示 首先在前台设置样式 < ...

  3. openfire url get提交 中文乱码问题

    原因是它只接受url编码后的中文 如:%E7%BC%96%E7%A0%81%E5%90%8E%E7%9A%84%E4%B8%AD%E6%96%87 会自动转变为:http://127.0.0.1:90 ...

  4. 说一下zoom:1的原理,万一被问到呢?

    某一天.前同事低着头从鹅厂面试回来.他说他被一道非经常见的问题难倒了. 对方问他知道zoom:1的作用吗? 前同事:清楚浮动啊,触发haslayout. 再问:那你知道zoom:1的工作原理和来龙去脉 ...

  5. android基站定位程序获取地理位置

    目录 一.设置界面 二.为按钮绑定事件 三.获取基站信息 四.获取经纬度 五.获取物理位置 六.显示结果 七.运行程序 八.总结 九.程序代码 正文 在Android操作系统下,基站定位其实很简单,先 ...

  6. There are inconsistent line endings in the 'xxx' script. Some are Mac OS X (UNIX) and some are Windows.问题解决

    在Window上使用Visual Studio编辑Unity3D脚本时常会出现类似如下警告: 警告 1 There are inconsistent line endings in the 'Asse ...

  7. java图形化Swing教程(一)

    与多线程.泛型等不同,Swing主要在于使用. 以下主要放代码和凝视.少说话. (一)基本框架 package Swing; import java.awt.*; import javax.swing ...

  8. 超全面的JavaWeb笔记day21<过滤器>

    1.过滤器的原理 2.实现过滤器 写一个类实现javax.servlet.Filter接口 在web.xml中对Filter进行配置 3.Filter接口 void init(FilterConfig ...

  9. Java集合----List集合

    List List 代表一个元素有序.且可重复的集合,集合中的每个元素都有其对应的顺序索引List 允许使用重复元素,可以通过索引来访问指定位置的集合元素.List 默认按元素的添加顺序设置元素的索引 ...

  10. swift - UIToolbar 的用法

    代码如下: 1.声明及初始化 var toolsBar = UIToolbar() toolsBar.frame = CGRect(x:, y:, width:SCREEN_WIDTH, height ...