使用 hostapd 的 dnsmasq 问题

使用 hostapd 的 dnsmasq 问题

首先我要为我的糟糕英语道歉......

我在使用 hostapd 时遇到错误,最确切地说是使用 dnsmasq 时遇到错误:当我编辑 /etc/dnsmasq.conf 并刷新它时,出现一条错误消息:

root@bob-E202SA:/home/bob/Scripts# sudo /etc/init.d/dnsmasq restart
[....] Restarting dnsmasq (via systemctl): dnsmasq.serviceJob for dnsmasq.service failed because the control process exited with error code. See "systemctl status dnsmasq.service" and "journalctl -xe" for details.
 failed!

好的,我这么做了:

root@bob-E202SA:/home/bob/Scripts# systemctl status dnsmasq.service
● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
   Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset: enabled)
  Drop-In: /run/systemd/generator/dnsmasq.service.d
           └─50-dnsmasq-$named.conf, 50-insserv.conf-$named.conf
   Active: failed (Result: exit-code) since mar. 2018-04-03 14:35:33 CEST; 5h 1min ago
  Process: 3351 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=2)
  Process: 3348 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCCESS)

april 03 14:35:33 bob-E202SA systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server...
april 03 14:35:33 bob-E202SA dnsmasq[3348]: dnsmasq: verifying syntax OK.
april 03 14:35:33 bob-E202SA dnsmasq[3351]: dnsmasq: unknown interface wlx00c0ca964944
april 03 14:35:33 bob-E202SA systemd[1]: dnsmasq.service: Control process exited, code=exited status=2
april 03 14:35:33 bob-E202SA systemd[1]: Failed to start dnsmasq - A lightweight DHCP and caching DNS server.
april 03 14:35:33 bob-E202SA systemd[1]: dnsmasq.service: Unit entered failed state.
april 03 14:35:33 bob-E202SA systemd[1]: dnsmasq.service: Failed with result 'exit-code'.

Hostapd 工作正常,我可以看到并将我的智能手机连接到互联网,但谷歌页面无法加载,并显示“此网站无法访问”,我认为问题出在 dnsmasq,这是由于这些错误消息造成的...谢谢你的帮助!!

编辑:这是“ifconfig -a”的输出

root@bob-E202SA:/home/bob# ifconfig -a
lo        Link encap:Boucle locale  
          inet adr:127.0.0.1  Masque:255.0.0.0
          adr inet6: ::1/128 Scope:Hôte
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          Packets reçus:7308 erreurs:0 :0 overruns:0 frame:0
          TX packets:7308 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 lg file transmission:1000 
          Octets reçus:563568 (563.5 KB) Octets transmis:563568 (563.5 KB)

wlp1s0    Link encap:Ethernet  HWaddr 30:5a:3a:89:2d:ee  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          Packets reçus:10 erreurs:0 :0 overruns:0 frame:0
          TX packets:22 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 lg file transmission:1000 
          Octets reçus:1433 (1.4 KB) Octets transmis:3929 (3.9 KB)

wlx00c0ca964944 Link encap:Ethernet  HWaddr 00:c0:ca:96:49:44  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          Packets reçus:0 erreurs:0 :16 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 lg file transmission:1000 
          Octets reçus:834 (834.0 B) Octets transmis:8040 (8.0 KB)

这是我的 /etc/network/interface

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

allow-hotplug wlp1s0
auto wlp1s0
iface wlp1s0 inet dhcp

allow-hotplug wlx00c0ca964944
iface wlx00c0ca964944 inet static
        address 10.0.0.1
        netmask 255.255.255.0
        network 10.0.0.0
        broadcast 10.0.0.255

我的 hostapd 脚本

#!/bin/sh
iInf="wlp1s0"  #Interface with Internet Connectivity (ex: eth0)
wInf="wlx00c0ca964944"  #Wireless interface (ex: wlan2)

sudo rm /var/run/hostapd/wlx00c0ca964944
sudo service dnsmasq stop
echo "Stopping port 5353 ..."
sudo kill -9 $( lsof -i:5353 -t )
echo "Bringing down wireless interface ..."
sudo ifconfig $wInf down
echo "Starting hostapd ..."
sudo hostapd -dd -B /etc/hostapd/hostapd.conf
echo "Configuring wireless interface ..."
sudo ifconfig $wInf 10.0.0.1 netmask 255.255.255.0

echo "Starting dnsmasq as DHCP server ..."
sudo dnsmasq
echo "Stopping firewall and allowing everyone ..."
sudo iptables -F
sudo iptables -X
sudo iptables -t nat -F
sudo iptables -t nat -X
sudo iptables -t mangle -F
sudo iptables -t mangle -X
sudo iptables -P INPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
sudo iptables -P OUTPUT ACCEPT
echo "Enabling NAT ..."
sudo iptables -t nat -A POSTROUTING -o $iInf -j MASQUERADE
echo "Enabling IP forwarding ..."
echo 1 > /proc/sys/net/ipv4/ip_forward
echo "Wireless gateway setup is complete"

...还有我的 /etc/dnsmasq.conf

port=5353
no-resolv
server=8.8.8.8
server=8.8.4.4
interface=wlx00c0ca964944
dhcp-range=10.0.0.3,10.0.0.20,12h

相关内容