柳罐罐 2018-07-01 16:25 采纳率: 30.8%
浏览 3804
已结题

用树莓派3创建AP热点出现了连接不能建立的情况

因为实验需要,从导师那里获取了一个树莓派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能搜索得到但是就是连接不上去,这是怎么一回事呢?

  • 写回答

2条回答 默认 最新

  • xdlzyq 2018-07-02 02:37
    关注
    1. dnsmasq服务没有起来,导致手机通过验证后获取不了IP地址
    2. 查看系统(ifconfig -a), 端口wlan1的名称是否为wlan1?
    3. dhcp配置里启用了一个pool,端口wlan1上有没有设置IP?例如:192.168.150.1/24
    评论

报告相同问题?

悬赏问题

  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用