因为实验需要,从导师那里获取了一个树莓派3和外接无线网卡
虽然树莓派自带了一个无线网卡,但是我的任务是用外接的无线网卡去创建一个AP热点,注意是外接的,机器自带的是wlan0,我的外接无线网卡是wlan1
在此之前用我从github上获取了一个ap-hotspot的shell脚本,该脚本集合了hostapd命令和dnsmasq命令,我在上面做了一些实验所需的修改并且在笔记本电脑ubuntu系统自带的无线网卡上成功建立了AP热点并能够成功连接
但是实验是要在树莓派3上面完成的,所以我把成功实行的脚本和相关文件拷贝到了树莓派3自带系统上了,经过一系列的调试,成功在树莓派3上运行了脚本并且成功的创建了AP热点,但是当我想要用我的安卓设备连接这个热点的时候,问题出现了,手机一直在连接但是连接不上去,一直在获取ip地址,我就想着可能是dnsmasq服务出了问题,果然我去树莓派上试了试,start这个service发现
Job for dnsmasq.service failed. See 'systemctl status dnsmasq.service' and 'journalctl -xn' for details.
出现了这样的提示
我用这个systemctl status dnsmasq.service命令出现了这样的提示
root@raspberrypi:/# systemctl status dnsmasq.service
● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
Loaded: loaded (/lib/systemd/system/dnsmasq.service; disabled)
Drop-In: /run/systemd/generator/dnsmasq.service.d
└─50-dnsmasq-$named.conf, 50-insserv.conf-$named.conf
Active: failed (Result: exit-code) since Sun 2018-07-01 23:27:13 JST; 43s ago
Process: 4417 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=1/FAILURE)
Process: 4413 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCCESS)
Jul 01 23:27:13 raspberrypi dnsmasq[4413]: dnsmasq: syntax check OK.
Jul 01 23:27:13 raspberrypi dnsmasq[4417]: dnsmasq: junk found in command line
Jul 01 23:27:13 raspberrypi systemd[1]: dnsmasq.service: control process exited, code=exited status=1
Jul 01 23:27:13 raspberrypi systemd[1]: Failed to start dnsmasq - A lightweight DHCP and caching DNS server.
Jul 01 23:27:13 raspberrypi systemd[1]: Unit dnsmasq.service entered failed state.
dnsmasq.conf文件的配置,由于我使用的是ap-hotspot脚本里面的默认配置,我并没有去修改,只不过可能在路径上有所不同
在ap-hotspot脚本里我设置成了自己的路径
dnsmasqcinfig="/home/pi/wifitest/mydnsmasq.conf"
默认配置如下
root@raspberrypi:/# cat /etc/dnsmasq.conf
bind-interfaces
interface=wlan1
dhcp-range=192.168.150.2,192.168.150.10,12h
系统的日志我也不大会看,只能找到这样的
日志文件
Jul 1 06:21:59 raspberrypi systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server...
Jul 1 06:21:59 raspberrypi dnsmasq[1119]: dnsmasq: syntax check OK.
Jul 1 06:21:59 raspberrypi dnsmasq[1123]: dnsmasq: junk found in command line
Jul 1 06:21:59 raspberrypi dnsmasq[1123]: junk found in command line
Jul 1 06:21:59 raspberrypi dnsmasq[1123]: FAILED to start up
Jul 1 06:21:59 raspberrypi systemd[1]: dnsmasq.service: control process exited, code=exited status=1
Jul 1 06:21:59 raspberrypi systemd[1]: Failed to start dnsmasq - A lightweight DHCP and caching DNS server.
Jul 1 06:21:59 raspberrypi systemd[1]: Dependency failed for Host and Network Name Lookups.
Jul 1 06:21:59 raspberrypi systemd[1]: Unit dnsmasq.service entered failed state.
关于网络设置,在这里
root@raspberrypi:/etc/network# cat interfaces
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
iface eth0 inet manual
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
在网上查了很多资料,运行sudo dnsmasq
然后出现了 dnsmasq:unknown interface wlan1 这样的返回,但是wlan1明明是我的外接无线网卡的啊
有没有对这方面了解的大神能帮忙解惑一下子吗,到底是不是我的dnsmasq出了问题呢?因为我已经成功建立了AP能搜索得到但是就是连接不上去,这是怎么一回事呢?