我正在尝试使用外部 USB WiFi 卡以及 hostapd 和 dsnmasq 在 Raspberry Pi 3 上设置 AP。我已经成功地使用内部 WiFi 卡实现了这一目标,但是当我尝试切换到外部 WiFi 卡时,出现以下错误:
$ sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf
Configuration file: /etc/hostapd/hostapd.conf
nl80211: Could not configure driver mode
nl80211: deinit ifname=wlan1 disabled_11b_rates=0
nl80211 driver initialization failed.
wlan1: interface state UNINITIALIZED->DISABLED
wlan1: AP-DISABLED
hostapd_free_hapd_data: Interface wlan1 wasn't started
我相信这是因为默认情况下 hostapd 使用nl80211
驱动程序。这是lsusb
-的输出Bus 001 Device 004: ID 148f:3072 Ralink Technology, Corp. RT3072 Wireless Adapter
。这是的输出lshw
*-network:1
description: Wireless interface
physical id: 3
bus info: usb@1:1.4
logical name: wlan1
serial: 98:3f:9f:24:a2:00
capabilities: ethernet physical wireless
configuration: broadcast=yes driver=rt2800usb driverversion=4.14.71-v7+ firmware=0.36 ip=10.100.100.254 link=no m
ulticast=yes wireless=IEEE 802.11
显然这张卡正在使用rt2080usb
驱动程序,但是当我尝试将其放入hostapd.conf
并手动启动时,hostapd
出现以下错误:
$ sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf
Configuration file: /etc/hostapd/hostapd.conf
Line 3: invalid/unknown driver 'rt2080usb'
1 errors found in configuration file '/etc/hostapd/hostapd.conf'
Failed to set up interface with /etc/hostapd/hostapd.conf
Failed to initialize interface
这是我的hostapd.conf
文件:
interface=wlan1
ssid=WiPi
driver=rt2080usb
hw_mode=g
ieee80211n=1
wmm_enabled=1
channel=4
macaddr_acl=0
auth_algs=3
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=wifipasswordhere
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
ht_capab=[HT20][SHORT-GI-20]
[编辑] 这是命令的输出iwconfig
:
wlan1 IEEE 802.11 ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=20 dBm
Retry short long limit:2 RTS thr:off Fragment thr:off
Power Management:off
wlan0 IEEE 802.11 ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=31 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:on
这是命令的输出iw list
:
valid interface combinations:
* #{ AP, mesh point } <= 8,
total <= 8, #channels <= 1
[编辑2] 这是我启动“hostapd”时的输出:
$ sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf
Configuration file: /etc/hostapd/hostapd.conf
Using interface wlan1 with hwaddr 98:3f:9f:24:a2:00 and ssid "WiPi"
random: Only 16/20 bytes of strong random data available from /dev/random
random: Not enough entropy pool available for secure operations
WPA: Not enough entropy in random pool for secure operations - update keys later when the first station connects
wlan1: interface state UNINITIALIZED->ENABLED
wlan1: AP-ENABLED
这是输出iwconfig
:
wlan1 IEEE 802.11 Mode:Master Tx-Power=20 dBm
Retry short long limit:2 RTS thr:off Fragment thr:off
Power Management:off
这是hostapd
我尝试连接到我的 essid WiPi 并运行速度测试时的日志:
$ Configuration file: /etc/hostapd/hostapd.conf
Using interface wlan1 with hwaddr 98:3f:9f:24:a2:00 and ssid "WiPi"
wlan1: interface state UNINITIALIZED->ENABLED
wlan1: AP-ENABLED
wlan1: STA 94:65:2d:d4:e0:5b IEEE 802.11: authenticated
wlan1: STA 94:65:2d:d4:e0:5b IEEE 802.11: associated (aid 1)
wlan1: AP-STA-CONNECTED 94:65:2d:d4:e0:5b
wlan1: STA 94:65:2d:d4:e0:5b RADIUS: starting accounting session 5BEC735C-00000000
wlan1: STA 94:65:2d:d4:e0:5b WPA: pairwise key handshake completed (RSN)
wlan1: AP-STA-DISCONNECTED 94:65:2d:d4:e0:5b
Failed to set beacon parameters
wlan1: INTERFACE-DISABLED
wlan1: INTERFACE-ENABLED
Failed to set beacon parameters
wlan1: INTERFACE-DISABLED
wlan1: INTERFACE-ENABLED
Failed to set beacon parameters
handle_probe_req: send failed
[编辑3]:我已将hostapd
调试模式运行sudo hostapd -dd -P /run/hostapd.pid -B -f /tmp/hostapd.log /etc/hostapd/hostapd.conf
设置为打开并将日志文件上传到帕斯特宾
答案1
这应该有帮助: https://www.ibm.com/developerworks/library/l-wifiencrypthostapd/index.html
https://wiki.gentoo.org/wiki/Hostapd
auth_algs=1 #限制为wpa
wpa=1 #限制为wpa
另外:您设置了 ieee80211n=1 和 hw_mode=g 设置,尝试设置 ieee80211n=0 或删除该选项,看看是否有帮助。
如果您根本不打算使用内部卡,我会将内部卡列入黑名单,然后配置外部卡以与 hostapd 一起使用,或者如果安装了 GUI,则只需使用连接管理器中的 setup ap 选项来共享您的有线联系。如果您尝试上述任一选项,请确保您修改的所有文件(控制 hostapd 的文件除外)都恢复为原始文件。