Posted on 2012-11-27 17:16
Milo的海域 閱讀(663)
評論(0) 編輯 收藏 所屬分類:
Linux
今天有同事反應一個網絡現象,一個多網卡環境,發給eth1的數據包都被eth0接收了。
第一印象是arp的問題。Google了下得到了確認,有個相關的kernal參數:
arp_ignore - INTEGER
Define different modes for sending replies in response to
received ARP requests that resolve local target IP addresses:
0 - (default): reply for any local target IP address, configured
on any interface
1 - reply only if the target IP address is local address
configured on the incoming interface
2 - reply only if the target IP address is local address
configured on the incoming interface and both with the
sender's IP address are part from same subnet on this interface
3 - do not reply for local addresses configured with scope host,
only resolutions for global and link addresses are replied
4-7 - reserved
8 - do not reply for all local addresses
默認是0,解決這個問題需要配置為1
臨時配置下
sysctl -w net.ipv4.conf.all.arp_ignore=1
持久配置
sysctl -w net.ipv4.conf.all.arp_ignore=1
echo 'net.ipv4.conf.all.arp_ignore=1' >> /etc/sysctl.conf
這個弄好可以重啟network服務來確保其他機器更新arp cache,如果不方便重啟network,自己手動敲arping命令,比如
arping -q -A -c 1 -I eth1 10.197.24.177
這個命令是在 /etc/sysconfig/network-scripts/ifup-eth里看到的
如果機器比較少,也可以直接用arp -d 來刪除相關的cache,建議上面的那種發廣播的方式。