1、配置hostapd [root@rk3288:/]# cat /etc/hostapd.conf interface=wlan0 driver=nl80211 ssid=wt hw_mode=g channel=11 dtim_period=1 rts_threshold=2347 fragm_threshold=2346 macaddr_acl=0 auth_algs=3 ieee80211n=0 wpa=3 wpa_passphrase=qwert8642 wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP 2、配置dnsmasq [root@rk3288:/]# cat /etc/dnsmasq.conf interface=wlan0 bind-interfaces except-interface=lo dhcp-range=192.168.2.10,192.168.2.20,12h dhcp-option=3,192.168.2.1 dhcp-option=6,223.5.5.5 3、路由规则脚本 [root@rk3288:/]# cat home/wtap #!/bin/sh iptables -F iptables -X iptables -t nat -F iptables -t nat -X iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -o eth0 -j MASQUERADE iptables -A FORWARD -s 192.168.2.0/24 -o eth0 -j ACCEPT iptables -A FORWARD -d 192.168.2.0/24 -m conntrack --ctstate ESTABLISHED,RELATED -i eth0 -j ACCEPT 4、打开路由转发 [root@rk3288:/]# cat /etc/sysctl.conf # /etc/sysctl.conf - Configuration file for setting system variables # See /etc/sysctl.d/ for additional system variables. # See sysctl.conf (5) for information. # Uncomment the next line to enable packet forwarding for IPv4 net.ipv4.ip_forward=1 5、启动AP [root@rk3288:/]# killall named killall: named: no process killed [root@rk3288:/]# killall hostapd killall: hostapd: no process killed [root@rk3288:/]# ifconfig wlan0 192.168.2.1 [root@rk3288:/]# [root@rk3288:/]# hostapd -B /etc/hostapd.conf Configuration file: /etc/hostapd.conf [ 493.643371] wl_cfg80211_del_station: Disconnect STA : ff:ff:ff:ff:ff:ff scb_val.val 3 Using interface wlan0 with hwaddr 94:a1:a2:1b:44:f2 and ssid "wt" [ 493.729952] dhd_wl_ioctl_set_intiovar: set int iovar ndoe failed, ERR -23 [ 493.736741] dhd_ndo_enable: failed to enabe ndo to 0, retcode = -23 [ 493.743036] CFG80211-ERROR) wl_cfg80211_start_ap : wl_cfg80211_start_ap: Disabling NDO Failed -23 [ 493.752771] wl_cfg80211_set_channel: netdev_ifidx(4), chan_type(1) target channel(11) [ 493.837268] wl_iw_event: Link UP with 94:a1:a2:1b:44:f2 [ 493.843432] wl_notify_connect_status_ap: ** AP/GO Link up event ** [ 493.851862] CFG80211-ERROR) wl_cfg80211_set_scb_timings : set 'scb_probe' failed, error = -23 [ 493.860683] CFG80211-ERROR) wl_cfg80211_start_ap : scb setting failed wlan0: interface state UNINITIALIZED->ENABLED wlan0: AP-ENABLED [root@rk3288:/]# /etc/init.d/dnsmasq restart Terminated [root@rk3288:/]# echo 1 >/proc/sys/net/ipv4/ip_forward [root@rk3288:/]# ./home/wtap [root@rk3288:/]# [root@rk3288:/]# [root@rk3288:/]# ifconfig eth0 Link encap:Ethernet HWaddr 9E:40:B6:56:5B:3A inet addr:192.168.1.32 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: 240e:390:8bc:bd30::3/128 Scope:Global inet6 addr: fe80::7f55:611f:b93:9e4b/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:104 errors:0 dropped:0 overruns:0 frame:0 TX packets:121 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:10476 (10.2 KiB) TX bytes:10998 (10.7 KiB) Interrupt:40 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:72 errors:0 dropped:0 overruns:0 frame:0 TX packets:72 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1 RX bytes:5328 (5.2 KiB) TX bytes:5328 (5.2 KiB) wlan0 Link encap:Ethernet HWaddr 94:A1:A2:1B:44:F2 inet addr:192.168.2.1 Bcast:192.168.2.255 Mask:255.255.255.0 inet6 addr: fe80::b4fd:dbfd:d93d:2769/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:29 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:6152 (6.0 KiB) 6、打开手机WLAN可以看到热点“wt”,连接该热点 板子上log如下: [root@rk3288:/]# [ 658.538293] wl_notify_connect_status_ap: connected device b0:e1:7e:3c:23:38 [ 658.548514] CFG80211-ERROR) wl_cfg80211_change_station : WLC_SCB_AUTHORIZE sta_flags_mask not set [ 658.598070] ETHER_TYPE_802_1X[wlan0] [TX]: ver 2, type 3, replay 1 [ 658.615240] ETHER_TYPE_802_1X[wlan0] [RX]: ver 1, type 3, replay 1 [ 658.622077] ETHER_TYPE_802_1X[wlan0] [TX]: ver 2, type 3, replay 2 [ 658.636723] ETHER_TYPE_802_1X[wlan0] [RX]: ver 1, type 3, replay 2 [ 658.645011] ETHER_TYPE_802_1X[wlan0] [TX]: ver 2, type 3, replay 3 [ 658.667957] ETHER_TYPE_802_1X[wlan0] [RX]: ver 1, type 3, replay 3 [ 694.854661] wl_notify_connect_status_ap: event WLC_E_DISASSOC_IND(12) status 0 reason 8 [ 694.863136] wl_notify_connect_status_ap: disassociated device b0:e1:7e:3c:23:38 [ 694.882671] wl_cfg80211_del_station: Disconnect STA : b0:e1:7e:3c:23:38 scb_val.val 3 [ 696.064659] wl_notify_connect_status_ap: connected device b0:e1:7e:3c:23:38 [ 696.074309] CFG80211-ERROR) wl_cfg80211_change_station : WLC_SCB_AUTHORIZE sta_flags_mask not set [ 696.101601] ETHER_TYPE_802_1X[wlan0] [TX]: ver 2, type 3, replay 1 [ 696.115376] ETHER_TYPE_802_1X[wlan0] [RX]: ver 1, type 3, replay 1 [ 696.124163] ETHER_TYPE_802_1X[wlan0] [TX]: ver 2, type 3, replay 2 [ 696.139159] ETHER_TYPE_802_1X[wlan0] [RX]: ver 1, type 3, replay 2 [ 696.152020] ETHER_TYPE_802_1X[wlan0] [TX]: ver 2, type 3, replay 3 [ 696.169684] ETHER_TYPE_802_1X[wlan0] [RX]: ver 1, type 3, replay 3 [ 732.283022] wl_notify_connect_status_ap: event WLC_E_DISASSOC_IND(12) status 0 reason 8 [ 732.291757] wl_notify_connect_status_ap: disassociated device b0:e1:7e:3c:23:38 [ 732.310281] wl_cfg80211_del_station: Disconnect STA : b0:e1:7e:3c:23:38 scb_val.val 3 [ 733.386774] wl_notify_connect_status_ap: connected device b0:e1:7e:3c:23:38 [ 733.396069] CFG80211-ERROR) wl_cfg80211_change_station : WLC_SCB_AUTHORIZE sta_flags_mask not set [ 733.424180] ETHER_TYPE_802_1X[wlan0] [TX]: ver 2, type 3, replay 1 [ 733.438731] ETHER_TYPE_802_1X[wlan0] [RX]: ver 1, type 3, replay 1 [ 733.447405] ETHER_TYPE_802_1X[wlan0] [TX]: ver 2, type 3, replay 2 [ 733.462306] ETHER_TYPE_802_1X[wlan0] [RX]: ver 1, type 3, replay 2 [ 733.474936] ETHER_TYPE_802_1X[wlan0] [TX]: ver 2, type 3, replay 3 [ 733.497181] ETHER_TYPE_802_1X[wlan0] [RX]: ver 1, type 3, replay 3 手机端一直处于提示“正在连接‘wt’”,最后提示超时,连接失败。请问,如何解决?非常感谢!
|