Hostapd SSID 几秒钟后消失

Gue*_*OCs 5 networking wifi hostapd network-interface

我正在使用 hostapd 通过我的树莓派零和 wifi 卡共享另一个 wifi 连接。树莓派启动后,我可以在手机中看到我的 SSID,甚至可以连接到它并使用它几秒钟。然后 SSID 就消失了。

\n\n

hostapd的状态显示没有任何错误:

\n\n
pi@raspberrypi:~ $ sudo service hostapd status\n\xe2\x97\x8f hostapd.service - LSB: Advanced IEEE 802.11 management daemon\n   Loaded: loaded (/etc/init.d/hostapd; generated; vendor preset: enabled)\n   Active: active (running) since Sun 2018-08-05 16:55:06 UTC; 6min ago\n     Docs: man:systemd-sysv-generator(8)\n  Process: 557 ExecStart=/etc/init.d/hostapd start (code=exited, status=0/SUCCESS)\n   CGroup: /system.slice/hostapd.service\n           \xe2\x94\x94\xe2\x94\x80597 /usr/sbin/hostapd -B -P /run/hostapd.pid /etc/hostapd/hostapd.conf\n\nAug 05 16:55:04 raspberrypi systemd[1]: Starting LSB: Advanced IEEE 802.11 management daemon...\nAug 05 16:55:06 raspberrypi hostapd[557]: Starting advanced IEEE 802.11 management: hostapd.\nAug 05 16:55:06 raspberrypi systemd[1]: Started LSB: Advanced IEEE 802.11 management daemon.\n
Run Code Online (Sandbox Code Playgroud)\n\n

这是我的 dmesg:

\n\n
[    9.951912] bcm2835_alsa bcm2835_alsa: card created with 8 channels\n[   10.988983] brcmfmac: F1 signature read @0x18000000=0x1541a9a6\n[   11.023394] brcmfmac: brcmf_fw_map_chip_to_name: using brcm/brcmfmac43430-sdio.bin for chip 0x00a9a6(43430) rev 0x000001\n[   11.023812] usbcore: registered new interface driver brcmfmac\n[   11.550743] brcmfmac: brcmf_c_preinit_dcmds: Firmware version = wl0: Oct 23 2017 03:55:53 version 7.45.98.38 (r674442 CY) FWID 01-e58d219f\n[   11.551907] brcmfmac: brcmf_c_preinit_dcmds: CLM version = API: 12.2 Data: 7.11.15 Compiler: 1.24.2 ClmImport: 1.24.1 Creation: 2014-05-26 10:53:55 Inc Data: 9.10.39 Inc Compiler: 1.29.4 Inc ClmImport: 1.36.3 Creation: 2017-10-23 03:47:14 \n[   12.469798] Indeed it is in host mode hprt0 = 00001101\n[   14.180038] uart-pl011 20201000.serial: no DMA platform data\n[   14.366758] usb 1-1: reset high-speed USB device number 2 using dwc_otg\n[   14.366994] Indeed it is in host mode hprt0 = 00001101\n[   16.080543] Adding 102396k swap on /var/swap.  Priority:-2 extents:1 across:102396k SSFS\n[   16.161385] mt7601u 1-1:1.0: ASIC revision: 76010001 MAC revision: 76010500\n[   16.252009] mt7601u 1-1:1.0: Warning: unsupported EEPROM version 0d\n[   16.252028] mt7601u 1-1:1.0: EEPROM ver:0d fae:00\n[   16.771510] ieee80211 phy1: Selected rate control algorithm 'minstrel_ht'\n[   16.776815] usbcore: registered new interface driver mt7601u\n[   18.456287] IPv6: ADDRCONF(NETDEV_UP): wlan1: link is not ready\n[   18.625722] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready\n[   18.625756] brcmfmac: power management disabled\n[   18.753324] Bluetooth: Core ver 2.22\n[   18.753500] NET: Registered protocol family 31\n[   18.753508] Bluetooth: HCI device and connection manager initialized\n[   18.753534] Bluetooth: HCI socket layer initialized\n[   18.753548] Bluetooth: L2CAP socket layer initialized\n[   18.753612] Bluetooth: SCO socket layer initialized\n[   18.781182] Bluetooth: HCI UART driver ver 2.3\n[   18.781197] Bluetooth: HCI UART protocol H4 registered\n[   18.781202] Bluetooth: HCI UART protocol Three-wire (H5) registered\n[   18.786141] Bluetooth: HCI UART protocol Broadcom registered\n[   19.362969] Bluetooth: BNEP (Ethernet Emulation) ver 1.3\n[   19.362997] Bluetooth: BNEP filters: protocol multicast\n[   19.363027] Bluetooth: BNEP socket layer initialized\n[   20.245972] wlan1: authenticate with 48:ee:0c:1f:d8:73\n[   20.308671] wlan1: send auth to 48:ee:0c:1f:d8:73 (try 1/3)\n[   20.310399] wlan1: authenticated\n[   20.313517] wlan1: associate with 48:ee:0c:1f:d8:73 (try 1/3)\n[   20.317906] wlan1: RX AssocResp from 48:ee:0c:1f:d8:73 (capab=0x411 status=0 aid=7)\n[   20.362268] wlan1: associated\n[   21.491599] IPv6: ADDRCONF(NETDEV_CHANGE): wlan1: link becomes ready\n[   32.303384] nf_conntrack version 0.5.0 (7168 buckets, 28672 max)\n[   33.692972] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready\n
Run Code Online (Sandbox Code Playgroud)\n\n

wlan1是树莓派连接的无线网络。wlan0是树莓派自带的内置wifi。我没有看到任何错误。

\n\n

这是/var/log/syslog

\n\n
Aug  5 16:55:06 raspberrypi kernel: [   33.692972] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready\nAug  5 16:55:06 raspberrypi hostapd[557]: Starting advanced IEEE 802.11 management: hostapd.\nAug  5 16:55:06 raspberrypi dnsmasq[599]: started, version 2.76 cachesize 150\nAug  5 16:55:06 raspberrypi systemd[1]: Started LSB: Advanced IEEE 802.11 management daemon.\nAug  5 16:55:06 raspberrypi dnsmasq[599]: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth DNSSEC loop-detect inotify\nAug  5 16:55:06 raspberrypi dnsmasq-dhcp[599]: DHCP, IP range 192.168.4.2 -- 192.168.4.20, lease time 1d\nAug  5 16:55:06 raspberrypi dnsmasq[599]: reading /run/dnsmasq/resolv.conf\nAug  5 16:55:06 raspberrypi dnsmasq[599]: using nameserver 192.168.25.1#53\nAug  5 16:55:06 raspberrypi dnsmasq[599]: read /etc/hosts - 5 addresses\nAug  5 16:55:06 raspberrypi dnsmasq[600]: Too few arguments.\nAug  5 16:55:06 raspberrypi systemd[1]: Started dnsmasq - A lightweight DHCP and caching DNS server.\nAug  5 16:55:06 raspberrypi systemd[1]: Reached target Multi-User System.\nAug  5 16:55:06 raspberrypi systemd[1]: Reached target Graphical Interface.\nAug  5 16:55:06 raspberrypi systemd[1]: Starting Update UTMP about System Runlevel Changes...\nAug  5 16:55:06 raspberrypi systemd[1]: Reached target Host and Network Name Lookups.\nAug  5 16:55:06 raspberrypi systemd[1]: Started Update UTMP about System Runlevel Changes.\nAug  5 16:55:06 raspberrypi systemd[1]: Startup finished in 1.995s (kernel) + 32.367s (userspace) = 34.362s.\nAug  5 16:55:07 raspberrypi avahi-daemon[188]: Joining mDNS multicast group on interface wlan0.IPv6 with address fe80::ba27:ebff:feaa:1f8.\nAug  5 16:55:07 raspberrypi avahi-daemon[188]: New relevant interface wlan0.IPv6 for mDNS.\nAug  5 16:55:07 raspberrypi avahi-daemon[188]: Registering new address record for fe80::ba27:ebff:feaa:1f8 on wlan0.*.\nAug  5 16:55:28 raspberrypi systemd[1]: Time has been changed\nAug  5 16:55:28 raspberrypi systemd[1]: apt-daily-upgrade.timer: Adding 27min 26.673226s random time.\nAug  5 16:55:28 raspberrypi systemd-timesyncd[173]: Synchronized to time server [2a01:4f8:110:30e1::9]:123 (2.debian.pool.ntp.org).\nAug  5 16:55:28 raspberrypi systemd[1]: apt-daily.timer: Adding 7h 36min 12.296585s random time.\nAug  5 17:01:05 raspberrypi systemd[1]: Created slice User Slice of pi.\nAug  5 17:01:05 raspberrypi systemd[1]: Started Session c1 of user pi.\nAug  5 17:01:05 raspberrypi systemd[1]: Starting User Manager for UID 1000...\nAug  5 17:01:06 raspberrypi systemd[668]: Listening on GnuPG cryptographic agent and passphrase cache.\nAug  5 17:01:06 raspberrypi systemd[668]: Listening on GnuPG cryptographic agent (access for web browsers).\nAug  5 17:01:06 raspberrypi systemd[668]: Listening on GnuPG cryptographic agent and passphrase cache (restricted).\nAug  5 17:01:06 raspberrypi systemd[668]: Reached target Timers.\nAug  5 17:01:06 raspberrypi systemd[668]: Reached target Paths.\nAug  5 17:01:06 raspberrypi systemd[668]: Listening on GnuPG cryptographic agent (ssh-agent emulation).\nAug  5 17:01:06 raspberrypi systemd[668]: Reached target Sockets.\nAug  5 17:01:06 raspberrypi systemd[668]: Reached target Basic System.\nAug  5 17:01:06 raspberrypi systemd[668]: Reached target Default.\nAug  5 17:01:06 raspberrypi systemd[668]: Startup finished in 178ms.\nAug  5 17:01:06 raspberrypi systemd[1]: Started User Manager for UID 1000.\nAug  5 17:02:40 raspberrypi wpa_supplicant[373]: wlan1: WPA: Group rekeying completed with 48:ee:0c:1f:d8:73 [GTK=CCMP]\n
Run Code Online (Sandbox Code Playgroud)\n\n

我也没有看到任何错误

\n\n

更新: \n该问题似乎仅在有人连接到网络后才会发生。系统日志上的最后消息是

\n\n
Aug  5 17:39:27 raspberrypi hostapd: wlan0: STA 38:80:df:35:8a:d3 IEEE 802.11: associated\nAug  5 17:39:27 raspberrypi hostapd: wlan0: STA 38:80:df:35:8a:d3 RADIUS: starting accounting session 5B672BEA-00000000\nAug  5 17:39:27 raspberrypi hostapd: wlan0: STA 38:80:df:35:8a:d3 WPA: pairwise key handshake completed (RSN)\nAug  5 17:39:27 raspberrypi dnsmasq-dhcp[599]: DHCPDISCOVER(wlan0) 38:80:df:35:8a:d3\nAug  5 17:39:27 raspberrypi dnsmasq-dhcp[599]: DHCPOFFER(wlan0) 192.168.4.16 38:80:df:35:8a:d3\nAug  5 17:39:27 raspberrypi dnsmasq-dhcp[599]: DHCPREQUEST(wlan0) 192.168.4.16 38:80:df:35:8a:d3\nAug  5 17:39:27 raspberrypi dnsmasq-dhcp[599]: DHCPACK(wlan0) 192.168.4.16 38:80:df:35:8a:d3\nAug  5 17:41:35 raspberrypi hostapd: wlan0: STA 38:80:df:35:8a:d3 IEEE 802.11: disassociated\nAug  5 17:41:35 raspberrypi hostapd: wlan0: STA 38:80:df:35:8a:d3 IEEE 802.11: disassociated\n
Run Code Online (Sandbox Code Playgroud)\n\n

但我没有看到任何错误。

\n\n

更新:

\n\n

这是我的/etc/hostapd/hostapd.conf文件:

\n\n
interface=wlan0\ndriver=nl80211\nssid=NameOfNetwork\nhw_mode=g\nchannel=7\nwmm_enabled=0\nmacaddr_acl=0\nauth_algs=1\nignore_broadcast_ssid=0\nwpa=2\nwpa_passphrase=AardvarkBadgerHedgehog\nwpa_key_mgmt=WPA-PSK\nwpa_pairwise=TKIP\nrsn_pairwise=CCMP\n
Run Code Online (Sandbox Code Playgroud)\n\n

更新:

\n\n

这是更详细的 hostapd:

\n\n
Aug  5 18:21:22 raspberrypi systemd[1]: Started User Manager for UID 1000.\nAug  5 18:21:40 raspberrypi hostapd: wlan0: STA 38:80:df:35:8a:d3 IEEE 802.11: associated\nAug  5 18:21:40 raspberrypi hostapd: wlan0: STA 38:80:df:35:8a:d3 WPA: event 1 notification\nAug  5 18:21:40 raspberrypi hostapd: wlan0: STA 38:80:df:35:8a:d3 WPA: start authentication\nAug  5 18:21:40 raspberrypi hostapd: wlan0: STA 38:80:df:35:8a:d3 IEEE 802.1X: unauthorizing port\nAug  5 18:21:40 raspberrypi hostapd: wlan0: STA 38:80:df:35:8a:d3 WPA: sending 1/4 msg of 4-Way Handshake\nAug  5 18:21:40 raspberrypi hostapd: wlan0: STA 38:80:df:35:8a:d3 WPA: EAPOL-Key timeout\nAug  5 18:21:40 raspberrypi hostapd: wlan0: STA 38:80:df:35:8a:d3 WPA: sending 1/4 msg of 4-Way Handshake\nAug  5 18:21:40 raspberrypi hostapd: wlan0: STA 38:80:df:35:8a:d3 WPA: received EAPOL-Key frame (2/4 Pairwise)\nAug  5 18:21:40 raspberrypi hostapd: wlan0: STA 38:80:df:35:8a:d3 WPA: sending 3/4 msg of 4-Way Handshake\nAug  5 18:21:40 raspberrypi hostapd: wlan0: STA 38:80:df:35:8a:d3 WPA: received EAPOL-Key frame (4/4 Pairwise)\nAug  5 18:21:40 raspberrypi hostapd: wlan0: STA 38:80:df:35:8a:d3 IEEE 802.1X: authorizing port\nAug  5 18:21:40 raspberrypi hostapd: wlan0: STA 38:80:df:35:8a:d3 RADIUS: starting accounting session 5B674006-00000000\nAug  5 18:21:40 raspberrypi hostapd: wlan0: STA 38:80:df:35:8a:d3 WPA: pairwise key handshake completed (RSN)\nAug  5 18:21:40 raspberrypi dnsmasq-dhcp[599]: DHCPDISCOVER(wlan0) 38:80:df:35:8a:d3\nAug  5 18:21:40 raspberrypi dnsmasq-dhcp[599]: DHCPOFFER(wlan0) 192.168.4.16 38:80:df:35:8a:d3\nAug  5 18:21:40 raspberrypi dnsmasq-dhcp[599]: DHCPREQUEST(wlan0) 192.168.4.16 38:80:df:35:8a:d3\nAug  5 18:21:40 raspberrypi dnsmasq-dhcp[599]: DHCPACK(wlan0) 192.168.4.16 38:80:df:35:8a:d3\nAug  5 18:21:54 raspberrypi systemd[664]: Time has been changed\nAug  5 18:21:54 raspberrypi systemd[1]: Time has been changed\nAug  5 18:21:54 raspberrypi systemd[1]: apt-daily.timer: Adding 10h 13min 39.087355s random time.\nAug  5 18:21:54 raspberrypi systemd[1]: apt-daily-upgrade.timer: Adding 28min 49.504522s random time.\nAug  5 18:22:27 raspberrypi systemd[1]: Time has been changed\nAug  5 18:22:27 raspberrypi systemd[1]: apt-daily.timer: Adding 55min 40.693498s random time.\nAug  5 18:22:27 raspberrypi systemd[1]: apt-daily-upgrade.timer: Adding 23min 53.062642s random time.\nAug  5 18:22:27 raspberrypi systemd[664]: Time has been changed\nAug  5 18:24:06 raspberrypi hostapd: wlan0: STA 38:80:df:35:8a:d3 IEEE 802.11: disassociated\nAug  5 18:24:06 raspberrypi hostapd: wlan0: STA 38:80:df:35:8a:d3 WPA: event 2 notification\nAug  5 18:24:06 raspberrypi hostapd: wlan0: STA 38:80:df:35:8a:d3 IEEE 802.1X: unauthorizing port\nAug  5 18:24:14 raspberrypi hostapd: wlan0: STA 38:80:df:35:8a:d3 IEEE 802.11: disassociated\n
Run Code Online (Sandbox Code Playgroud)\n\n

更新:

\n\n

我之前已经用 USB 以太网设置了这个树莓派。我现在重新安装了一个新的映像,并刚刚配置了无线 AP 功能所需的内容。问题仍然发生。之后它仍然会发生sudo apt update && sudo apt upgrade -y,所以它看起来更像是一个错误而不是错误的配置。

\n\n

有人知道如何调试它吗?

\n

Rob*_*Rob 0

我可以在手机中看到我的 SSID,甚至可以连接并使用它几秒钟。然后 SSID 就消失了。

在/etc/hostapd/hostapd.conf中,您有以下默认值:

# Send empty SSID in beacons and ignore probe request frames that do not 
# specify full SSID, i.e., require stations to know SSID. 
# default: disabled (0) 
# 1 = send empty (length=0) SSID in beacon and ignore probe request for 
#     broadcast SSID 
# 2 = clear SSID (ASCII 0), but keep the original length (this may be required 
#     with some clients that do not support empty SSID) and ignore probe 
#     requests for broadcast 
SSID ignore_broadcast_ssid=0
Run Code Online (Sandbox Code Playgroud)

确保它已被禁用且未被更改。

另外,这篇 Raspberry.PI 文章:“让 wifi 与隐藏网络一起工作”建议:

“您必须将 scan_ssid=1 添加到 /etc/wpa_supplicant/wpa_supplicant.conf 文件中。”。

例子:

network={
ssid="bigboss"
scan_ssid=1
psk="mypassword"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
auth_alg=OPEN
}
Run Code Online (Sandbox Code Playgroud)