树莓派上可以直接用命令安装hostapd。
apt-get install hostapd
使用时遇到错误日志:
random: Only 15/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
显示随机池取数不够。
起初使用简单粗暴方法,直接将/dev/random 修改成/dev/urandom。
$mv /dev/random /dev/random.bak
$ln -s /dev/urandom /dev/random
但这样会影响其他程序对/dev/random的使用,所以重新编译hostapd替换直接安装上的hostapd。
一、下载hostapd源码
可从官方网站下载所需安装包http://w1.fi/releases/。
我使用2.4版本编译安装。
二、配置hostapd
cp defconfig .config
修改hostapd-2.4/src/crypto/random.c文件
fd = open(“/dev/random”, O_RDONLY | O_NONBLOCK);改成
fd = open(“/dev/urandom”, O_RDONLY | O_NONBLOCK);
三、安装编译所需库
错误:../src/drivers/driver_nl80211.c:17:31: fatal error: netlink/genl/genl.h:
解决:apt-get install libnl-dev
错误:../src/crypto/tls_openssl.c:19:25: fatal error: openssl/ssl.h:
解决:apt-get install libssl1.0-dev
安装libssl-dev会继续报错
四、编译
make
将编译生成的hostapd、hostapd_cli 文件复制到/usr/sbin
将hostapd.conf复制到/etc/hostapd
五、执行
hostapd /etc/hostapd/hostapd.conf
六、设置开机启动
$service hostapd start
$update-rc.d hostapd enable