linux 双网卡在同一网段的解决办法

 

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).

 

vi /etc/rc.local

 

也可尝试以下方法(本人测试, 不能很好解决)

增加以下内容:

route add -net 0.0.0.0 netmask 0.0.0.0 gw 0.1.52.1 dev eth0

route add -net 0.0.0.0 netmask 0.0.0.0 gw 0.1.52.1 dev eth2

ip route add to 0.0.0.0/0 via 10.1.52.1 dev eth0 table 10

ip route add to 0.0.0.0/0 via 10.1.52.1 dev eth2 table 20

ip rule add from 10.1.52.226/32 table 10

ip rule add from 10.1.52.228/32 table 20

 

 

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值