Linux

同一介面上的客戶端之間沒有連接

  • March 27, 2017

我在 Linux 中配置無線介面時遇到問題。出於某種原因,由無線客戶端生成的發往同一介面上其他無線客戶端的流量會被丟棄(即 arp 請求、icmp 等)。

例如,10.0.1.2(連接到 wlan0)可以 ping 10.0.1.3(連接到 wlan1),反之亦然。但是,10.0.1.4(也連接到 wlan1)無法 ping 10.0.1.3。

有趣的是,wireshark 顯示傳入的數據包,因此它們正在到達介面。我目前將無線介面連接到網橋,但是沒有網橋也會出現問題。我還嘗試了各種客戶端的各種無線晶片,它們的行為方式都相同。此外,在無線客戶端上手動添加相關的 arp 記錄並不能解決問題。

對我來說,這似乎是我錯過的一些 sysctl 或 ip route 設置。任何投入將不勝感激。如果您需要我的配置的任何特定部分,請告訴我。

作為參考,我的 hostapd 配置中沒有設置 ap_isolate,我指定的唯一 sysctl 參數是 net.ipv4.ip_forward = 1,在 iptables 中配置了 NAT。

更新 1(相關 sysctl 配置):

net.ipv4.conf.wls15.accept_local = 0
net.ipv4.conf.wls15.accept_redirects = 1
net.ipv4.conf.wls15.accept_source_route = 1
net.ipv4.conf.wls15.arp_accept = 0
net.ipv4.conf.wls15.arp_announce = 0
net.ipv4.conf.wls15.arp_filter = 0
net.ipv4.conf.wls15.arp_ignore = 1
net.ipv4.conf.wls15.arp_notify = 0
net.ipv4.conf.wls15.bootp_relay = 0
net.ipv4.conf.wls15.disable_policy = 0
net.ipv4.conf.wls15.disable_xfrm = 0
net.ipv4.conf.wls15.drop_gratuitous_arp = 0
net.ipv4.conf.wls15.drop_unicast_in_l2_multicast = 0
net.ipv4.conf.wls15.force_igmp_version = 0
net.ipv4.conf.wls15.forwarding = 1
net.ipv4.conf.wls15.igmpv2_unsolicited_report_interval = 10000
net.ipv4.conf.wls15.igmpv3_unsolicited_report_interval = 1000
net.ipv4.conf.wls15.ignore_routes_with_linkdown = 0
net.ipv4.conf.wls15.log_martians = 0
net.ipv4.conf.wls15.mc_forwarding = 0
net.ipv4.conf.wls15.medium_id = 0
net.ipv4.conf.wls15.promote_secondaries = 0
net.ipv4.conf.wls15.proxy_arp = 0
net.ipv4.conf.wls15.proxy_arp_pvlan = 0
net.ipv4.conf.wls15.route_localnet = 0
net.ipv4.conf.wls15.rp_filter = 1
net.ipv4.conf.wls15.secure_redirects = 1
net.ipv4.conf.wls15.send_redirects = 1
net.ipv4.conf.wls15.shared_media = 1
net.ipv4.conf.wls15.src_valid_mark = 0
net.ipv4.conf.wls15.tag = 0

看起來啟用重定向解決了問題!

檢查無線設備的配置設置。該命令sysctl -a | grep ipv4.conf.wlan0應提供設置。這些是我配置的設置:

net.ipv4.conf.wlan0.accept_redirects = 1
net.ipv4.conf.wlan0.accept_source_route = 1
net.ipv4.conf.wlan0.arp_ignore = 1
net.ipv4.conf.wlan0.forwarding = 1
net.ipv4.conf.wlan0.secure_redirects = 1
net.ipv4.conf.wlan0.send_redirects = 1
net.ipv4.conf.wlan0.shared_media = 1

引用自:https://serverfault.com/questions/840732