有趣的手机配件:多个网卡同网段

来源:百度文库 编辑:中财网 时间:2024/04/28 17:19:24

如何解决Linux上插多个千兆网卡的问题

分类:默认栏目

问题:在linux上插了3块intel的以太千兆网卡,发现他们不能很好的工作,现象:

1.  一个网卡插了网线,所有配置的IP地址都可以用了

2.  一个网卡在收包但是却一个也不发,而另外一个却一直在发包,却一个也没有收到;

3.  一个主机ping这个有多个网卡的主机时,只有某一个网卡可以通,其他的网卡即使是up起来了,也插网线了,却始终连不通,而使用arp命令时却可以发现对方的MAC地址,就是连不通(世界上最远的距离不是我不知道你的地址,而是我知道你的地址却就是连不上你);

4.  arp命令时,不同IP地址的MAC地址是一样的,刚开机时如果不让系统自动加载网卡,若手工启动会发现,只要启动一个,其他的也都会一起起来,以后再up或down后就不会出现这个问题了。

 

解决过程:为了能搞懂到底什么地方出现了问题,我尝试了很多,不然也不会发现上面如此多的现象了,包括不使用交换机而使用网线直接连接起来....等等,后来发现网上有一篇文章叫《多个网卡绑定为一个IP地址》,以为找到了救星,因为看到其中有句话说,绑定时网卡有4种工作模式,一个叫负载均衡,一个叫主从工作的(另外两个就没有介绍了),还以为就是工作模式的问题,但想到现象2,就又否定了;然后等等其他的想法后来就都否定了。

 

解决方法:后来我想到去看intel的网卡驱动的说明文档,才有所顿悟(其实之前也看过这个文档,当时看的不仔细,加上现象还没有完全发现清楚,对他的解释没有注意到),下面是相关的一段原文:

Jumbo frames on Foundry BigIron 8000 switch
-------------------------------------------
There is a known issue using Jumbo frames when connected to a Foundry
BigIron 8000 switch.  This is a 3rd party limitation.  If you experience
loss of packets, lower the MTU size.

Multiple Interfaces on Same Ethernet Broadcast Network
------------------------------------------------------
Due to the default ARP behavior on Linux, it is not possible to have
one system on two IP networks in the same Ethernet broadcast domain
(non-partitioned switch) behave as expected.  All Ethernet interfaces
will respond to IP traffic for any IP address assigned to the system.
This results in unbalanced receive traffic.

If you have multiple interfaces in a server, either turn on ARP
filtering by entering:

    echo 1 > /proc/sys/net/ipv4/conf/all/arp_filter
(this only works if your kernel's version is higher than 2.4.5),

NOTE: This setting is not saved across reboots.  The configuration
change can be made permanent by adding the line:
    net.ipv4.conf.all.arp_filter = 1
to the file /etc/sysctl.conf

      or,

install the interfaces in separate broadcast domains (either in
different switches or in a switch partitioned to VLANs).

82541/82547 can't link or are slow to link with some link partners

也就是对一个主机上又多个网卡的时候,有两种方法,一是开ARP过滤功能,二是把两个网卡配置到两个不同的网段上,我使用第二种方法成功地解决了问题(其实这个方法很早就想过,但是对其可行性没有考虑清楚,就没有实施,浪费了这么多时间,想想还真是可惜呀)。

 

总结:

1.  看文档要细

2.  有了想法,就要认真想想,想不明白就试试