1、编译hostapd需要libnl库和openssl库,所以要下载这两个库的源代码,进行交叉编译。
2、下载libnl源码,并解压
3、# cd ~/hostapd# tar -jxvf libnl-1.1.tar.gz
4、进入libnl-1.1 配置
5、# cd ~/hostapd/libnl-1.1# ./configure --host=arm-linux幻腾寂埒-guneabi-gcc - --prefix=/usr/local/arm/libnl1.1# add #include <limits.h> in netlink-local.h
6、编译安装# make CC=arm-linux-guneabi-gcc # make install
7、下载openssl-1.0.0e.tar.gz源码,并解压# cd ~/hostapd# tar -jxvf openssl-1.0.0e.tar.gz
8、进入openssl-1.0.0e# ./config --host=arm-linux-guneabi-gcc - --prefix=/usr/local/arm/openssl# make install
9、编译安装# make CC=arm-linux-guneabi-gcc # make install
10、到reltek网站下载RTL8188的linux驱动,驱动代码包里有专用的hostapd。解压源文件;# tar -jxvf rtl8188EUS_linux_v4.1.4_6773.20130222.tar.gz
11、配置# cp defconfig .config# vi .config增加CONFIG_DRIVER_RTW=y(这个非常关键,增加了reltek芯片的驱动)注释掉#CONFIG_DRIVER_NL80211=y去掉CONFIG_WPS=y前注释去除CONFIG_IEEE80211N=y前注释
12、编译生成二进制文件hostapd# make CC=arm-linux-guneabi-gcc
13、将hostapd拷贝到目标机某个目录下运行(如:/home/hostapd)。拭貉强跳# insmod /lib/modules/3.14.38-6UL_ga\+ge4944a5/kernel/drivers/net/wireless/realtek/rtl8188EUS/8188eu.ko# ifconfig wlan0 up # ifconfig wlan0 192.168.10.1 netmask 255.255.255.0 # udhcpd /etc/udhcpd.conf & # /home/hostapd -d /etc/hostapd.conf &
14、卸载载方法如下# 坡纠课柩ifconfig wlan0 down# ifconfig usb0 down# pkill -f "hostapd"# pkill -f "udhcpd"# killall udhcpc# rmmod 8188euudhcpd 配置文件修改
15、udhcpd 配置文件修改# vi /etc/udhcpd.conf
16、# The start and end of the IP lease 水瑞侮瑜blockstart 192.168.2.2 #default: 192.168.0.20 分配的IP要与wlan0设置的IP处于同一网段end 192.168.2.100 #default: 192.168.0.254# The interface that udhcpd will useinterface wlan0 #default: eth0 interface设置为wlan0。# The maximim number of leases (includes addressesd reserved# by OFFER's, DECLINE's, and ARP confictsmax_leases 21 #default: 254opt dns 192.168.2.2 114.114.114.114 #192.168.10.2 192.168.10.10option subnet 255.255.255.0opt router 192.168.2.1 #192.168.10.2opt wins 192.168.2.10 #192.168.10.10option dns 129.219.13.81 # appened to above DNS servers for a total of 3option domain localoption lease 864000 # 10 days of seconds
17、hostapd 配置文件修改# vi /etc/hostapd.conf
18、将文件内容修改如下:interface=wlan0ssid=ZZT_SSIDd筠续师诈river=rtl871xdrvchannel=9hw_罪焐芡拂mode=gignore_broadcast_ssid=0auth_algs=1wpa=3wpa_passphrase=12345678wpa_key_mgmt=WPA-PSKwpa_pairwise=TKIPrsn_pairwise=CCMP