树莓派4插入eth0网线后USB无线网卡wlan1热点客户端无法ping通接口问题求助
树莓派4插入eth0网线后USB无线网卡wlan1热点客户端无法ping通接口问题求助
我在树莓派4(Raspbian系统)上成功用hostapd和isc-dhcpd把USB无线网卡wlan1配置成了AP(dhcpd只监听wlan1接口)。不管板载WiFi wlan0有没有连接到外网热点,wlan1的客户端都能ping通wlan1接口。IP转发和伪装都正常,当wlan0连上网时,wlan1的客户端也能正常访问外网,一切都很完美!
但是一插上eth0网线,情况就不对了:wlan1的客户端虽然显示已连接,但完全ping不通wlan1接口了,外网访问也跟着失效。
这太奇怪了!DHCP服务器给客户端分配的还是之前的有效IP,wlan1的静态IP也没变(eth0和wlan1都是静态IP)。树莓派本地能ping通wlan1,但外部客户端就是不行。拔掉eth0网线后,一切又恢复正常了。
到底哪里出问题了?为什么连接口都ping不通了?已经开启了sysctl IPv4转发。
网络接口信息
$ ip link 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 4: wlan1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
IP地址配置
$ ip addr ... 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether e4:5f:01:84:db:34 brd ff:ff:ff:ff:ff:ff inet 10.8.0.2/8 brd 10.255.255.255 scope global noprefixroute eth0 valid_lft forever preferred_lft forever ... 3: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000 link/ether e4:5f:01:84:db:37 brd ff:ff:ff:ff:ff:ff 4: wlan1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether a0:f3:c1:23:2d:62 brd ff:ff:ff:ff:ff:ff inet 10.8.5.1/8 brd 10.255.255.255 scope global noprefixroute wlan1 valid_lft forever preferred_lft forever ...
nftables规则
$nft list ruleset ... table ip nat { chain postrouting { type nat hook postrouting priority srcnat; policy accept; masquerade } } ...
hostapd配置文件内容
$ cat /etc/hostapd/hostapd.conf interface=wlan1 #If this fails, try rt1871xdrv a #driver=nl80211 # Name of the new network: best use the hostname ssid=xxx # Pick a channel not already in use channel=1 # Change to b for older devices? hw_mode=g macaddr_acl=0 auth_algs=3 # Disable this to insure the AP is visible: ignore_broadcast_ssid=0 wpa=2 wpa_passphrase=xxx wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP #bridge=br0 # no bridge! We're using routing country_code=JP
dhcpcd配置文件内容
$ cat /etc/dhcpcd.conf ... interface eth0 static ip_address=10.8.0.2/8 static routers=10.8.0.1 static domain_name_servers=127.0.0.1 interface wlan1 static ip_address=10.8.5.1/8 nohook wpa_supplicant static domain_name_servers=127.0.0.1 interface wlan0 static domain_name_servers=127.0.0.1
dhcpd配置文件内容
$ cat /etc/dhcp/dhcpd.conf ... authoritative; subnet 10.8.5.0 netmask 255.255.255.0 { range 10.8.5.201 10.8.5.250; option broadcast-address 10.8.5.255; option routers 10.8.5.1; default-lease-time 600; max-lease-time 7200; option domain-name "local"; option domain-name-servers 10.8.5.1; } host ares { hardware ethernet 04:ea:56:ae:58:03; fixed-address 10.8.5.20; }
Windows 11客户端IP配置信息
$ ipconfig # on Windows 11 Client ... Wireless LAN adapter Wi-Fi: Connection-specific DNS Suffix . : local Description . . . . . . . . . . . : Intel(R) Dual Band Wireless-AC 8265 Physical Address. . . . . . . . . : 04-EA-56-AE-58-03 DHCP Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes Link-local IPv6 Address . . . . . : fe80::9300:7ccf:3e03:eaf9%17(Preferred) IPv4 Address. . . . . . . . . . . : 10.8.5.20(Preferred) Subnet Mask . . . . . . . . . . . : 255.255.255.0 Lease Obtained. . . . . . . . . . : Friday, 16 December 2022 22:56:38 Lease Expires . . . . . . . . . . : Friday, 16 December 2022 23:06:37 Default Gateway . . . . . . . . . : 10.8.5.1 DHCP Server . . . . . . . . . . . : 10.8.5.1 DHCPv6 IAID . . . . . . . . . . . : 168094294 DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-26-1E-05-25-48-2A-E3-3A-C9-F0 DNS Servers . . . . . . . . . . . : 10.8.5.1 NetBIOS over Tcpip. . . . . . . . : Enabled ...
备注:内容来源于stack exchange,提问作者Arakis
相关产品推荐
相关产品推荐

