本文共 1206 字,大约阅读时间需要 4 分钟。
什么是hostapd
hostapd 是用户控件的守护进程用于无线接入点(AP)和授权服务器(authentication servers). 她实现了IEEE802.11的AP管理,IEEE802.1X/WPA/WPA2/EAP授权,RADIUS 客户端,EAP服务器和RADIUS 授权服务器,目前最新版本支持Linux系统(HOST AP,madwifi,mac80211-based驱动)和FreeBSD(net80211)。 hostapd设计为一个守护程序(进程),后台运行,进行一些相关控制授权的操作。属于一个开源项目。 ————————————————
执行如下脚本即可
killall -q wpa_supplicant
killall -q udhcpc killall -q udhcpd killall -q hostapd # 以上清除当前网络相关进程是必须的,不然WiFi还有可能工作在sta模式下 echo "start switch to AP mode..." ifconfig wlan0 down# 设置当前网卡IP为192.168.43.1,和udhcpd 里面IP要相同
ifconfig wlan0 192.168.43.1 up #启动hostap 工具,记得-B表示后台运行 hostapd -B hostapd.cfg # 启动udhcpd 设置ip地址范围,dns等 udhcpd udhcpd.confhostapd.cfg
interface=wlan0
ctrl_interface=/var/run/hostapd ssid=ap_ssid wpa=2 wpa_key_mgmt=WPA-PSK wpa_pairwise=CCMP wpa_passphrase=12345678 channel=3 driver=nl80211 wme_enabled=1 ieee80211n=1 hw_mode=g ht_capab=[SHORT-GI-20][SHORT-GI-40][HT40+] auth_algs=1 max_num_sta=8 udhcpd.confstart 192.168.43.20
end 192.168.43.254 interface wlan0 lease_file /var/run/udhcpd.leases opt dns 8.8.8.8 8.8.4.4 option subnet 255.255.255.0 opt router 192.168.43.1 opt wins 0.0.0.0 option domain local option lease 864000 ap 开启成功后,ifconfig 会有ip ,route 有网关,这样手机连接上就可以ping 通了。 ————————————————转载地址:http://yqdxi.baihongyu.com/