3

我有一个 raspberry PI 2 并已将 HOSTAPD 和 udhcpd 配置为热点。我遇到的第一个问题是司机。我购买的 WiFi 适配器是 Realtek 芯片组。现在通过关注这篇文章解决了这个问题。 https://www.raspberrypi.org/forums/view ... hp?t=62371

现在我面临的第二个问题是 WPA2 身份验证。如果我将 hostapd 设置为 open\no 身份验证,它就像一个魅力。如果我设置身份验证,我将无法连接。Andriod 设备绕着连接转,iPhone 回来时密码不正确——即使我认为我输入了正确的密码。

以下是 hostapd.conf 中的配置和来自 hostapd --ddK /etc/hostapd/hostapd.conf 的日志

interface=wlan0
#driver=
ssid=<removed>
hw_mode=g
channel=1
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=<removed>
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

#log
logger_syslog=-1
logger_syslog_level=2
logger_stdout=-1
logger_stdout_level=2


pi@raspberrypi ~ $ sudo hostapd -ddK /etc/hostapd/hostapd.conf
random: Trying to read entropy from /dev/random
Configuration file: /etc/hostapd/hostapd.conf
nl80211: interface wlan0 in phy phy0
rfkill: initial event: idx=0 type=1 op=0 soft=0 hard=0
nl80211: Using driver-based off-channel TX
nl80211: Add own interface ifindex 3
nl80211: Set mode ifindex 3 iftype 3 (AP)
nl80211: Create interface iftype 6 (MONITOR)
nl80211: New interface mon.wlan0 created: ifindex=6
nl80211: Add own interface ifindex 6
BSS count 1, BSSID mask 00:00:00:00:00:00 (0 bits)
nl80211: Regulatory information - country=00
nl80211: 2402-2472 @ 40 MHz
nl80211: 2457-2482 @ 20 MHz
nl80211: 2474-2494 @ 20 MHz
nl80211: 5170-5250 @ 80 MHz
nl80211: 5250-5330 @ 80 MHz
nl80211: 5490-5730 @ 160 MHz
nl80211: 5735-5835 @ 80 MHz
nl80211: 57240-63720 @ 2160 MHz
nl80211: Added 802.11b mode based on 802.11g information
Allowed channel: mode=1 chan=1 freq=2412 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=2 freq=2417 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=3 freq=2422 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=4 freq=2427 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=5 freq=2432 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=6 freq=2437 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=7 freq=2442 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=8 freq=2447 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=9 freq=2452 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=10 freq=2457 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=11 freq=2462 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=1 freq=2412 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=2 freq=2417 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=3 freq=2422 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=4 freq=2427 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=5 freq=2432 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=6 freq=2437 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=7 freq=2442 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=8 freq=2447 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=9 freq=2452 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=10 freq=2457 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=11 freq=2462 MHz max_tx_power=20 dBm
Completing interface initialization
Mode: IEEE 802.11g  Channel: 1  Frequency: 2412 MHz
nl80211: Set freq 2412 (ht_enabled=0 sec_channel_offset=0)
RATE[0] rate=10 flags=0x1
RATE[1] rate=20 flags=0x1
RATE[2] rate=55 flags=0x1
RATE[3] rate=110 flags=0x1
RATE[4] rate=60 flags=0x0
RATE[5] rate=90 flags=0x0
RATE[6] rate=120 flags=0x0
RATE[7] rate=180 flags=0x0
RATE[8] rate=240 flags=0x0
RATE[9] rate=360 flags=0x0
RATE[10] rate=480 flags=0x0
RATE[11] rate=540 flags=0x0
Flushing old station entries
Deauthenticate all stations
wpa_driver_nl80211_set_key: ifindex=3 alg=0 addr=(nil) key_idx=0 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=3 alg=0 addr=(nil) key_idx=1 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=3 alg=0 addr=(nil) key_idx=2 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=3 alg=0 addr=(nil) key_idx=3 set_tx=0 seq_len=0 key_len=0
Using interface wlan0 with hwaddr 40:a5:ef:07:b4:0e and ssid 'kid'
Deriving WPA PSK based on passphrase
SSID - hexdump_ascii(len=3):
     6b 69 64                                          <removed>             
PSK (ASCII passphrase) - hexdump_ascii(len=8):
     4b 69 64 31 32 33 34 35                           <removed>       
PSK (from passphrase) - hexdump(len=32): eb f3 9f 60 48 03 d8 c2 6d 29 b5 34 1f 22 fe cd 02 ff 43 6e 7e 35 88 d9 41 49 42 27 26 c5 08 ad
random: Got 16/20 bytes from /dev/random
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
Get randomness: len=32 entropy=0
GMK - hexdump(len=32): 8b 1b 05 6b 6c a3 27 3b 7d 4c 8d 08 75 c0 94 2e e9 ad cd 06 90 6b c3 8f 10 74 96 6e 07 a7 44 b7
Get randomness: len=32 entropy=0
Key Counter - hexdump(len=32): 8d 5d 7d 92 d4 6c 8b 56 cd f2 10 a6 4a ba 4f c9 96 1d 93 28 db d2 3b 1d e2 a2 74 02 c8 41 cf 26
WPA: Delay group state machine start until Beacon frames have been configured
VLAN: vlan_set_name_type(name_type=2)
nl80211: Set beacon (beacon_set=0)
WPA: Start group state machine to set initial keys
WPA: group state machine entering state GTK_INIT (VLAN-ID 0)
Get randomness: len=16 entropy=0
GTK - hexdump(len=16): ba 94 df 43 2f 11 50 e1 86 45 25 87 fb 9a f3 b8
WPA: group state machine entering state SETKEYSDONE (VLAN-ID 0)
wpa_driver_nl80211_set_key: ifindex=3 alg=3 addr=0x890c8 key_idx=1 set_tx=1 seq_len=0 key_len=16
   broadcast key
wpa_driver_nl80211_set_operstate: operstate 0->1 (UP)
netlink: Operstate: linkmode=-1, operstate=6
Failed to set TX queue parameters for queue 0.
Failed to set TX queue parameters for queue 1.
Failed to set TX queue parameters for queue 2.
Failed to set TX queue parameters for queue 3.
wlan0: Setup of interface done.
random: Got 4/4 bytes from /dev/random
RTM_NEWLINK: operstate=1 ifi_flags=0x1002 ()
nl80211: Ignore interface down event since interface wlan0 is up
RTM_NEWLINK: operstate=1 ifi_flags=0x1002 ()
nl80211: Ignore interface down event since interface mon.wlan0 is up
RTM_NEWLINK: operstate=1 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])
RTM_NEWLINK, IFLA_IFNAME: Interface 'mon.wlan0' added
Unknown event 5
RTM_NEWLINK: operstate=1 ifi_flags=0x1003 ([UP])
RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added
nl80211: if_removed already cleared - ignore event
RTM_NEWLINK: operstate=1 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])
RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added
nl80211: if_removed already cleared - ignore event
VLAN: vlan_newlink(wlan0)
nl80211: Event message available
nl80211: New station <iphone MAC address>
nl80211: Event message available
nl80211: Delete station <iphone MAC address>
wlan0: WPA rekeying GTK
WPA: group state machine entering state SETKEYS (VLAN-ID 0)
Get randomness: len=16 entropy=0
GTK - hexdump(len=16): 06 b2 b8 05 a7 b6 a6 03 81 1b a4 9a 01 bb 8c 29
wpa_group_setkeys: GKeyDoneStations=0
WPA: group state machine entering state SETKEYSDONE (VLAN-ID 0)
wpa_driver_nl80211_set_key: ifindex=3 alg=3 addr=0x890c8 key_idx=2 set_tx=1 seq_len=0 key_len=16
   broadcast key
^CSignal 2 received - terminating
Flushing old station entries
Deauthenticate all stations
nl80211: Remove interface ifindex=6
netlink: Operstate: linkmode=0, operstate=6
nl80211: Set mode ifindex 3 iftype 2 (STATION)

我已尝试卸载并重新安装 hostapd

4

1 回答 1

2

我没有看到提到的 DHCP 服务器 - 这是使用 hostapd 设置无线网络的关键基础设施。有关设置 DHCP 服务器的换行符下方提供了更多信息。不过,在介绍之前,这里有一些包含更多一般信息的链接。所有链接都指向charlesreid1.com/wiki。我用它们来记录我将 Raspberry Pi 设置为无线接入点的过程。所有页面均指使用 Raspberry Pi 创建 wifi 网络/接入点:

以下是有关设置 DHCP 服务器的一些信息,以防将 Raspberry Pi 设置为无线 AP 时出现问题。


通过编辑设置 DHCP 服务器/etc/dhcp/dhcp.conf

首先,添加“权威”一词,表示这是网络上的权威DHCP。(您应该会看到一些注释和行已经填写在默认安装到 Raspberry Pi 上的 DHCP 配置文件中):

  # If this DHCP server is the official DHCP server for the local
  # network, the authoritative directive should be uncommented.
  authoritative;

取消评论权威。

然后在 DHCP 配置文件中添加一个块来设置 IP 地址分配/配置。我在我的家庭网络上使用 IP 子网 192.168.42.X。

  subnet 192.168.42.0 netmask 255.255.255.0 {
    range 192.168.42.10 192.168.42.50;
    option broadcast-address 192.168.42.255;
    option routers 192.168.42.1;
    default-lease-time 600;
    max-lease-time 7200;
    option domain-name "local";
    option domain-name-servers 8.8.8.8, 8.8.4.4;
  }

您不需要所有这些选项,但请尝试一下。

接下来,您需要告诉 DHCP 服务器使用哪个接口,以便您可以编辑/etc/default/isc-dhcp-server和更新该INTERFACES部分以指向您的特定接口:

INTERFACES="wlan0"

现在您需要更新您的网络接口,以便它知道不要尝试寻找 IP 地址。把界面拉下来,

$ sudo ifdown wlan0

然后编辑/etc/network/interfaces并手动将 Pi 的 IP 地址指定为网关地址(我再次使用 192.168.42.X 架构,但您可以使用任何您想要的,只要它与上面提到的 DHCP 配置文件匹配):

allow-hotplug wlan0

iface wlan0 inet static
    address 192.168.42.1
    netmask 255.255.255.0

最后一步是编辑您hostapd.conf已经完成的文件。这是启用 WPA2 后的样子(看起来您已经弄清楚了这部分并且可以正常工作):

interface=wlan0
driver=<insert driver here>
ssid=<insert SSID here>
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=<insert passphrase here>
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

希望这些信息中的一些有用......快乐的黑客!

于 2017-08-12T02:52:10.067 回答