具有 wpa_supplicant/WPA2 配置的 Raspberry Pi 3 Ad-Hoc 無線網絡

具有 wpa_supplicant/WPA2 配置的 Raspberry Pi 3 Ad-Hoc 無線網絡

我需要有關使用 wpa_supplicant 保護 Ad-Hoc 網路的協助。

我一直在嘗試使用板載 WiFi 適配器在 Raspberry PI 3 之間設定 Ad-Hoc 無線網路。

pi@raspberrypi3bare:~ $ iw list
Wiphy phy0
    max # scan SSIDs: 10
    max scan IEs length: 2048 bytes
    Retry short limit: 7
    Retry long limit: 4
    Coverage class: 0 (up to 0m)
    Device supports T-DLS.
    Supported Ciphers:
        * WEP40 (00-0f-ac:1)
        * WEP104 (00-0f-ac:5)
        * TKIP (00-0f-ac:2)
        * CCMP (00-0f-ac:4)
        * CMAC (00-0f-ac:6)
    Available Antennas: TX 0 RX 0
    Supported interface modes:
         * IBSS
         * managed
         * AP
         * P2P-client
         * P2P-GO
         * P2P-device
    Band 1:
        Capabilities: 0x1020
            HT20
            Static SM Power Save
            RX HT20 SGI
            No RX STBC
            Max AMSDU length: 3839 bytes
            DSSS/CCK HT40
        Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
        Minimum RX AMPDU time spacing: 16 usec (0x07)
        HT TX/RX MCS rate indexes supported: 0-7
        Bitrates (non-HT):
            * 1.0 Mbps
            * 2.0 Mbps (short preamble supported)
            * 5.5 Mbps (short preamble supported)
            * 11.0 Mbps (short preamble supported)
...
            * 54.0 Mbps
        Frequencies:
            * 2412 MHz [1] (20.0 dBm)
...
            * 2472 MHz [13] (20.0 dBm)
            * 2484 MHz [14] (disabled)
    Supported commands:
         * new_interface
         * set_interface
         * new_key
         * start_ap
         * join_ibss
         * set_pmksa
         * del_pmksa
         * flush_pmksa
         * remain_on_channel
         * frame
         * set_channel
         * tdls_oper
         * start_sched_scan
         * start_p2p_device
         * crit_protocol_start
         * crit_protocol_stop
         * connect
         * disconnect
    Supported TX frame types:
         * managed: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
         * P2P-client: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
         * P2P-GO: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
         * P2P-device: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
    Supported RX frame types:
         * managed: 0x40 0xd0
         * P2P-client: 0x40 0xd0
         * P2P-GO: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
         * P2P-device: 0x40 0xd0
    software interface modes (can always be added):
    valid interface combinations:
         * #{ managed } <= 1, #{ P2P-device } <= 1, #{ P2P-client, P2P-GO } <= 1,
           total <= 3, #channels <= 2
         * #{ managed } <= 1, #{ AP } <= 1, #{ P2P-client } <= 1, #{ P2P-device } <= 1,
           total <= 4, #channels <= 1

如上所述,支援P2P(Ad-Hoc)。

我的網路介面配置如下所示:

auto wlan0
iface wlan0 inet static
        address 192.168.0.10
        netmask 255.255.255.0
        wireless-channel 11
        wireless-essid FooBar2
        wireless-mode ad-hoc
#       wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

在沒有啟用 wpa_supplicant 的情況下,我可以在兩個不同的 Pi'es(兩個不同的 IP 位址)上啟動 wlan0,而且它運作正常。我可以從另一個 Pi 上 ping 通(反之亦然)。

當我嘗試在其上運行 wpa_supplicant 時(在兩個 Pi 上),我無法讓它們工作。

wpa_supplicant 設定檔如下所示:

pi@raspberrypi3bare:~ $ sudo cat /etc/wpa_supplicant/wpa_supp.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
ap_scan=2
network={
        ssid="FooBar2"
        key_mgmt=WPA-PSK
        psk=102ea4041e1612cc5905c4b9008f5e9aaebe91d20792ca16ab7754fd137865a8
        mode=1
        proto=RSN
        group=CCMP
        pairwise=CCMP
        frequency=2462
}

啟動命令的輸出:

pi@raspberrypi3bare:~ $ sudo wpa_supplicant -c /etc/wpa_supplicant/wpa_supp.conf -D nl80211 -i wlan0
Successfully initialized wpa_supplicant
Note: nl80211 driver interface is not designed to be used with ap_scan=2; this can result in connection failures
wlan0: Trying to associate with SSID 'FooBar2'
wlan0: Associated with 7e:6c:29:3d:49:eb
wlan0: CTRL-EVENT-CONNECTED - Connection to 7e:6c:29:3d:49:eb completed [id=0 id_str=]
WMM AC: Missing IEs
wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0


pi@raspberrypi3bare:~ $ ping 192.168.0.30
PING 192.168.0.30 (192.168.0.30) 56(84) bytes of data.
From 192.168.0.10 icmp_seq=1 Destination Host Unreachable

其他一些細節:

pi@raspberrypi3bare:~ $ wpa_supplicant -v
wpa_supplicant v2.6
Copyright (c) 2003-2016, Jouni Malinen <[email protected]> and contributors
pi@raspberrypi3bare:~ $ uname -a
Linux raspberrypi3bare 4.4.21-v7+ #911 SMP Thu Sep 15 14:22:38 BST 2016 armv7l GNU/Linux

知道我可以改變什麼來讓 wpa_supplicant 工作嗎?

答案1

順便一提:P2P 是 Wi-Fi Direct,這與 Ad Hoc 有很大不同。 Ad Hoc 專指 IBSS。本答案的其餘部分假設您指的是 IBSS,而不是 P2P。

透過 IBSS 進行 WPA2-PSK 身份驗證是可能的(IEEE 802.11 標準定義瞭如何做到這一點),但實現起來有點複雜,所以我不確定它的支援範圍有多大。如果wpa_supplicant 不支援它,我不會感到驚訝,因為它要求請求者切換角色並在某些情況下成為身份驗證者,而在其他情況下仍然充當請求者,具體取決於哪個設備具有更高的MAC地址。通常,WPA2-PSK 驗證器的角色由 AP 模式裝置上的 hostapd 扮演。我不確定 wpa_supplicant 中是否存在任何身份驗證器程式碼。

嘗試讓 Ad Hoc (IBSS) 與 40 位元 WEP 一起工作。完成工作後,請研究 wpa_supplicant 是否支援 IBSS 上的 WPA2-PSK,以及如何設定它。

相關內容