9615 wifi热点调试记录----热点连接

上一篇文章提到能成功开启热点,接下来就是调试热点连接了。热点调试以加密方式:

wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP

 扫描到热点后进行连接,客户端连接不上,提示鉴权问题。打印出以下错误的log:

  Using interface eth0 with hwaddr 00:03:7f:06:61:37 and ssid "AR6K-RSN-WPA"
random: Cannot read from /dev/random: Resource temporarily unavailable
random: Only 0/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
eth0: STA 20:59:a0:90:bf:4a IEEE 802.11: disassociated
eth0: STA 20:59:a0:90:bf:4a IEEE 802.11: associated
random: Cannot read from /dev/random: Resource temporarily unavailable
random: Only 0/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 to proceed - reject first 4-way handshake

eth0: STA 20:59:a0:90:bf:4a IEEE 802.11: disassociated
eth0: STA 20:59:a0:90:bf:4a IEEE 802.11: associated
random: Cannot read from /dev/random: Resource temporarily unavailable
random: Only 0/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 to proceed - reject first 4-way handshake

eth0: STA 20:59:a0:90:bf:4a IEEE 802.11: disassociated

因为随机数的产生问题导致4此握手失败,热点也自然连接不上。网上有人遇到过随机数产生问题,大概就是没有中断导致了随机数生成失败。把从/dev/random取随机数,改成了从/dev/urandom取随机数,鉴权问题得到了解决。但是依然是连接不上的,Log:

eth0: Event ASSOC (0) received
Add randomness: count=9 entropy=8
eth0: STA 20:59:a0:90:bf:4a IEEE 802.11: associated
STA included RSN IE in (Re)AssocReq  
New STA
ap_sta_add: register ap_handle_timertimeout for 20:59:a0:90:bf:4a (300 seconds - ap_max_inactivity)
ar6000_del_key:addr=20:59:a0:90:bf:4a key_idx=0
IEEE 802.1X: Ignore STA - 802.1X not enabled or forced for WPS
WPA: 20:59:a0:90:bf:4a WPA_PTK entering state INITIALIZE
ar6000_del_key: addr=20:59:a0:90:bf:4a key_idx=0
WPA: 20:59:a0:90:bf:4a WPA_PTK_GROUP entering state IDLE
WPA: 20:59:a0:90:bf:4a WPA_PTK entering state AUTHENTICATION
WPA: 20:59:a0:90:bf:4a WPA_PTK entering state AUTHENTICATION2
WPA: Re-initialize GMK/Counter on first stationGet randomness:len=32 entropy=9
Get randomness: len=32 entropy=0Get randomness: len=16 entropy=0
ar6000_set_key: alg=2 addr=ff:ff:ff:ff:ff:ff key_idx=1
Get randomness: len=32 entropy=0
WPA: 20:59:a0:90:bf:4a WPA_PTK entering state INITPSK
WPA: 20:59:a0:90:bf:4a WPA_PTK entering state PTKSTART
WPA: Send EAPOL(version=2 secure=0 mic=0 ack=1 install=0 pairwise=8 kde_len=0 keyidx=0 encr=0)
WPA: Use EAPOL-Key timeout of 1000 ms (retry counter 1)
hostapd_new_assoc_sta: reschedule ap_handle_timer timeout for 20:59:a0:90:bf:4a (300 seconds - ap_max_inactivity)
Wireless event: cmd=0x8c05 len=194
eth0: Event EAPOL_RX (27) received
IEEE 802.1X: 121 bytes from 20:59:a0:90:bf:4a
  IEEE 802.1X: version=1 type=3 length=117
WPA: Received EAPOL-Key from 20:59:a0:90:bf:4a key_info=0x10a type=2 key_data_length=22
Add randomness: count=10 entropy=0
WPA: 20:59:a0:90:bf:4a WPA_PTK entering state PTKCALCNEGOTIATING
WPA: PTK derivation - A1=00:03:7f:06:61:37 A2=20:59:a0:90:bf:4a
WPA: 20:59:a0:90:bf:4a WPA_PTKentering state PTKCALCNEGOTIATING2
WPA: 20:59:a0:90:bf:4a WPA_PTK entering statePTKINITNEGOTIATING
WPA: Send EAPOL(version=2 secure=1 mic=1 ack=1 install=1 pairwise=8 kde_len=94 keyidx=1 encr=1)
WPA: Use EAPOL-Key timeout of 1000 ms (retry counter 1)
eth0: Event EAPOL_RX (27) received
IEEE 802.1X: 99 bytes from 20:59:a0:90:bf:4a  
 IEEE 802.1X: version=1 type=3 length=95
WPA: Received EAPOL-Key from 20:59:a0:90:bf:4a key_info=0x30a type=2 key_data_length=0
WPA: 20:59:a0:90:bf:4a WPA_PTK entering state PTKINITDONE
ar6000_set_key: alg=3 addr=20:59:a0:90:bf:4a key_idx=0
eth0: AP-STA-CONNECTED 20:59:a0:90:bf:4a
eth0: STA 20:59:a0:90:bf:4a RADIUS: starting accounting session 53BCF6A8-00000000
eth0: STA 20:59:a0:90:bf:4a WPA: pairwise key handshake completed (RSN)

eth0: Event DISASSOC (1) received
eth0: STA 20:59:a0:90:bf:4a IEEE 802.11: disassociated
eth0: AP-STA-DISCONNECTED 20:59:a0:90:bf:4a
ar6000_del_key: addr=20:59:a0:90:bf:4a key_idx=0
WPA: 20:59:a0:90:bf:4a WPA_PTK entering state DISCONNECTED
WPA: 20:59:a0:90:bf:4aWPA_PTK entering state INITIALIZE
ar6000_del_key: addr=20:59:a0:90:bf:4a key_idx=0
ap_free_sta: cancel ap_handle_timer for 20:59:a0:90:bf:4a
Wireless event: cmd=0x8c02 len=21

收到了AP-STA-CONNECTED的消息以后,一下子又收到了DISASSOC请求,最终热点连接还是连接不成功。
我怀疑是没有分配IP地址导致了此问题,所有使用命令来配置动态IP。
/ # ifconfig eth0 192.168.43.1 netmask 255.255.255.0
ifconfig eth0 192.168.43.1 netmask 255.255.255.0
/ # echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/ip_forward
/ # dnsmasq --no-daemon --no-resolv --no-poll --dhcp-range=192.168.43.2,192.168.43.100
dnsmasq --no-daemon --no-resolv --no-poll --dhcp-range=192.168.43.2,192.168.43.100
dnsmasq: failed to bind DHCP server socket: Address already in use


提示地址已经被占用。这个问题查了很久,网上查找的资料说用地址复用,修改代码:
    if((setsockopt(srv->fd,SOL_SOCKET,SO_REUSEADDR,&on,sizeof(on)))<0)  
    {  
    wpa_printf(MSG_DEBUG, "HTTP: setsockopt fail!");
      goto fail;  
    }  
问题依旧存在,依然提示地址被占用了。一直纠结在socket被占用,用ps查看进程,确实启动了一个dnsmasq进程:
 217 nobody     0:00 /usr/bin/dnsmasq -7 /etc/dnsmasq.d
 有人遇到过启动热点后,客户端连接过来,分配不到IP的情况,重启了hostapd就可以了。我试着重启了下,不行。突然想到重启下dnsmasq,
  就想kill了 dnsmasq进程,在用dnsmasq命令去配置了ip:
   # ifconfig eth0 192.168.43.1 netmask 255.255.255.0
ifconfig eth0 192.168.43.1 netmask 255.255.255.0
# echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/ip_forward
 # dnsmasq --no-daemon --no-resolv --no-poll --dhcp-range=192.168.43.2,192.168.43.100
dnsmasq --no-daemon --no-resolv --no-poll --dhcp-range=192.168.43.2,192.168.43.100 
   地址被占用的命令竟然没有了。尝试着用其他设备连接了一下这个热点,连接成功。


你可能感兴趣的:(Wi-Fi)