我正在尝试设置我的树莓派以使用 realtek 8192eu 无线网卡,但运气不佳。我已经编译了 hostapd 和 8192eu 驱动程序。使用 /etc/network/interfaces 设置桥接器;创建了接入点,客户端可以成功关联。但几分钟后它们会主动断开关联,并且永远不会被分配 IP 地址。我思考这意味着 DHCP 请求没有通过桥接器传输。
root@walle:/home/xbian# cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo br0
iface lo inet loopback
# wireless wlan0
allow-hotplug wlan0
iface wlan0 inet manual
# eth0 connected to the ISP router
allow-hotplug eth0
iface eth0 inet manual
# Setup bridge
iface br0 inet static
bridge_ports wlan0 eth0
broadcast 192.168.0.255
address 192.168.0.10
netmask 255.255.255.0
network 192.168.0.0
## isp router ip, 192.168.1.2 also runs DHCPD ##
gateway 192.168.0.1
dns-nameservers 192.168.0.1
root@walle:/home/xbian# cat /etc/hostapd/hostapd.conf
# Basic configuration
interface=wlan0
ssid=wallesap
channel=1
bridge=br0
# WPA and WPA2 configuration
macaddr_acl=0
#auth_algs=1
#ignore_broadcast_ssid=0
#wpa=3
#wpa_passphrase=12345678
#wpa_key_mgmt=WPA-PSK
#wpa_pairwise=TKIP
#rsn_pairwise=CCMP
# Hardware configuration
ieee80211n=1
hw_mode=g
root@walle:/home/xbian# iwconfig
wlan0 IEEE 802.11bgn ESSID:"wallesap" Nickname:"<WIFI@REALTEK>"
Mode:Master Frequency:2.412 GHz Access Point: 00:13:EF:35:14:03
Bit Rate:144.4 Mb/s Sensitivity:0/0
Retry:off RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off
Link Quality=4/100 Signal level=4/100 Noise level=0/100
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
root@walle:/home/xbian# ifconfig
br0 Link encap:Ethernet HWaddr B8:27:EB:19:6F:E7
inet addr:192.168.0.10 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::ba27:ebff:fe19:6fe7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:726 errors:0 dropped:0 overruns:0 frame:0
TX packets:523 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:64454 (62.9 KiB) TX bytes:72419 (70.7 KiB)
eth0 Link encap:Ethernet HWaddr B8:27:EB:19:6F:E7
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:750 errors:0 dropped:0 overruns:0 frame:0
TX packets:523 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:69329 (67.7 KiB) TX bytes:78563 (76.7 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:58 errors:0 dropped:0 overruns:0 frame:0
TX packets:58 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:4022 (3.9 KiB) TX bytes:4022 (3.9 KiB)
wlan0 Link encap:Ethernet HWaddr 00:13:EF:35:14:03
inet6 addr: fe80::213:efff:fe35:1403/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:25 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2570 (2.5 KiB) TX bytes:1632 (1.5 KiB)
root@walle:/home/xbian# cat /proc/sys/net/ipv4/ip_forward
1
无奈之下,我甚至尝试安装 dnsmasq 并将其配置为在 wlan0 上分发地址,但没有任何运气。
编辑:后来,我尝试在 wlan0 上启用混杂模式:
wlan0 Link encap:Ethernet HWaddr 00:13:EF:35:14:03
inet6 addr: fe80::213:efff:fe35:1403/64 Scope:Link
UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
RX packets:16 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2336 (2.2 KiB) TX bytes:1632 (1.5 KiB)
如您所见,流量似乎在卡上流动,但这似乎对问题没有影响。也许桥也需要混杂?
在 AP 端,以下是 dmesg 输出:
[23201.874218] RTL871X: +OnAuth
[23201.874241] RTL871X: auth alg=0, seq=1
[23201.874253] RTL871X: going to alloc stainfo for sa=34:02:86:a1:8c:9f
[23201.874271] RTL871X: rtw_alloc_macid = 0
[23201.874288] RTL871X: issue_auth
[23201.878507] RTL871X: OnAssocReq
[23201.878522] RTL871X: IEEE 802.11 element parse ignored unknown element (id=127 elen=8)
[23201.878535] RTL871X: STA did not include WPA/RSN IE in (Re)Association Request - possible WPS use
[23201.878545] RTL871X: allocate new AID = (1)
[23201.878558] RTL871X: HT: STA 34:02:86:a1:8c:9f HT Capabilities Info: 0x11a5
[23201.878569] RTL871X: bss_cap_update_on_sta_join STA 34:02:86:a1:8c:9f - no greenfield, num of non-gf stations 1
[23201.878579] RTL871X: bss_cap_update_on_sta_join STA 34:02:86:a1:8c:9f - 20 MHz HT, num of 20MHz HT STAs 1
[23201.878587] RTL871X: bss_cap_update_on_sta_join, updated=0
[23201.878594] RTL871X: update_sta_info_apmode
[23201.878600] RTL871X: ### Set STA_(0) info
[23201.878612] RTL871X: issue_asocrsp
[23201.878642] RTL871X: report_add_sta_event: add STA
[23201.878725] RTL871X: ### rtl8192e_set_FwMediaStatus_cmd: MStatus=1 MACID=0
[23201.879306] RTL871X: add_RATid=> mac_id:0 , raid:2 , shortGIrate=0, bitmap=0xfffffff
[23201.879318] RTL871X: rtl8192e_set_raid_cmd, bitmap=0xfffffff, mac_id=0x0, raid=0x2, shortGIrate=0
[23201.880294] RTL871X: indicate_sta_assoc_event to upper layer - hostapd
[23201.880303] RTL871X: +rtw_indicate_sta_assoc_event
[23201.880474] RTL871X: rtw_get_sta_wpaie, sta_addr: 34:02:86:a1:8c:9f
[23201.880485] RTL871X: sta's wpa_ie is NONE
[23203.533749] RTL871X: add_RATid=> mac_id:0 , raid:2 , shortGIrate=0, bitmap=0xfffffff
[23203.533770] RTL871X: rtl8192e_set_raid_cmd, bitmap=0xf8ff000, mac_id=0x0, raid=0x2, shortGIrate=0
[23219.567406] RTL871X: issue_nulldata(wlan0) to 34:02:86:a1:8c:9f, ch:1, 1/1 in 6 ms
[23219.567425] RTL871X: ack check for asoc expire, keep_alive_trycnt=1
[23219.622116] RTL871X: wakeup_sta_to_xmit alive check
[23227.583586] RTL871X: issue_nulldata(wlan0) to 34:02:86:a1:8c:9f, ch:1, 1/1 in 6 ms
[23227.583604] RTL871X: ack check for asoc expire, keep_alive_trycnt=1
[23227.609353] RTL871X: wakeup_sta_to_xmit alive check
这看起来绝对是一次成功的关联尝试。
这是来自无线客户端的信息:
[25663.895131] wlo1: authenticate with 2c:b0:5d:cc:db:e2
[25663.901055] wlo1: send auth to 2c:b0:5d:cc:db:e2 (try 1/3)
[25663.928925] wlo1: authenticated
[25663.929530] wlo1: associate with 2c:b0:5d:cc:db:e2 (try 1/3)
[25663.987682] wlo1: associate with 2c:b0:5d:cc:db:e2 (try 2/3)
[25663.988717] wlo1: RX AssocResp from 2c:b0:5d:cc:db:e2 (capab=0x11 status=0 aid=3)
[25663.990808] wlo1: associated
[25712.996257] wlo1: deauthenticating from 2c:b0:5d:cc:db:e2 by local choice (Reason: 3=DEAUTH_LEAVING)
[25713.017426] cfg80211: World regulatory domain updated:
[25713.017430] cfg80211: DFS Master region: unset
[25713.017432] cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)
[25713.017435] cfg80211: (2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A, 2000 mBm), (N/A)
[25713.017438] cfg80211: (2457000 KHz - 2482000 KHz @ 40000 KHz), (N/A, 2000 mBm), (N/A)
[25713.017440] cfg80211: (2474000 KHz - 2494000 KHz @ 20000 KHz), (N/A, 2000 mBm), (N/A)
[25713.017442] cfg80211: (5170000 KHz - 5250000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (N/A)
[25713.017445] cfg80211: (5250000 KHz - 5330000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (0 s)
[25713.017447] cfg80211: (5490000 KHz - 5730000 KHz @ 160000 KHz), (N/A, 2000 mBm), (0 s)
[25713.017449] cfg80211: (5735000 KHz - 5835000 KHz @ 80000 KHz), (N/A, 2000 mBm), (N/A)
[25713.017451] cfg80211: (57240000 KHz - 63720000 KHz @ 2160000 KHz), (N/A, 0 mBm), (N/A)
[25713.021207] cfg80211: Regulatory domain changed to country: GB
[25713.021210] cfg80211: DFS Master region: ETSI
[25713.021211] cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)
[25713.021213] cfg80211: (2402000 KHz - 2482000 KHz @ 40000 KHz), (N/A, 2000 mBm), (N/A)
[25713.021214] cfg80211: (5170000 KHz - 5250000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (N/A)
[25713.021216] cfg80211: (5250000 KHz - 5330000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (0 s)
[25713.021217] cfg80211: (5490000 KHz - 5710000 KHz @ 160000 KHz), (N/A, 2700 mBm), (0 s)
[25713.021218] cfg80211: (57000000 KHz - 66000000 KHz @ 2160000 KHz), (N/A, 4000 mBm), (N/A)
[25738.000665] IPv6: ADDRCONF(NETDEV_UP): wlo1: link is not ready
[25750.500907] wlo1: authenticate with 2c:b0:5d:cc:db:e2
[25750.506858] wlo1: direct probe to 2c:b0:5d:cc:db:e2 (try 1/3)
[25750.710295] wlo1: direct probe to 2c:b0:5d:cc:db:e2 (try 2/3)
[25750.913310] wlo1: direct probe to 2c:b0:5d:cc:db:e2 (try 3/3)
[25751.114337] wlo1: authentication with 2c:b0:5d:cc:db:e2 timed out
[25763.024159] IPv6: ADDRCONF(NETDEV_UP): wlo1: link is not ready
所以,这看起来像是一个成功的关联事件,随后客户端选择断开连接。为什么会这样?可能是因为它没有及时收到 DHCP 租约?