castletonroad
Posts: 137
Joined: Sat Jul 25, 2015 11:23 pm

DNSMASQ problem

Sat Oct 29, 2016 9:13 am

So I've been a good boy and put /etc/network/interfaces back the way it shipped with Jessie. I'm now assigning my static IPs using /etc/dhcpd.conf.

Since this broke my WiFi AP configuration on wlan0, I decided to follow this link to get it back working again:

https://frillip.com/using-your-raspberr ... h-hostapd/

But when I:

Code: Select all

$ sudo service dnsmasq start
I get the error:

Code: Select all

failed to create listening socket for 192.168.10.1: Address already in use
/etc/dnsmasq.conf

Code: Select all

interface=wlan0
listen-address=192.168.10.1
bind-interfaces
server=8.8.8.8
domain-needed
bogus-priv
dhcp-range=192.168.10.10,192.168.10.20,12h


/etc/dhcpd.conf:

Code: Select all

denyinterfaces wlan0

interface eth0
 static ip_address=192.168.1.19/24
 static routers=192.168.1.1
 static domain_name_servers=192.168.1.1

#interface wlan0
# static ip_address=192.168.10.1/24
# static routers=192.168.10.1
# static domain_name_servers=192.168.10.1

interface wlan1
 static ip_address=192.168.1.21/24
 static routers=192.168.1.1
 static domain_name_servers=192.168.1.1
/etc/network/interfaces:

Code: Select all

source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback

iface eth0 inet manual
 pre-up /etc/firewall-openvpn-rules.sh

iface wlan0 inet static
 address 192.168.10.1
 netmask 255.255.255.0
 network 192.168.10.0
 broadcast 192.168.10.255

#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
(wlan0 is the AP, wlan1 is a network adaptor)

What am I missing?

Cheers :)
Raspberry Pi 4 Model B | Raspberry Pi 3 Model B | Raspberry Pi 2 Model B

epoch1970
Posts: 5888
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: DNSMASQ problem

Sat Oct 29, 2016 9:37 am

Does it work without bind-interfaces?
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

castletonroad
Posts: 137
Joined: Sat Jul 25, 2015 11:23 pm

Re: DNSMASQ problem

Sat Oct 29, 2016 11:35 pm

Yes. But see the following course of action...

1. '#'d out bind-interfaces, and then rebooted.

2. ifconfig output:

Code: Select all

wlan0     Link encap:Ethernet  HWaddr b8:27:eb:fe:7f:3a
inet6 addr: fe80::ba27:ebff:fefe:7f3a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:120932 errors:0 dropped:120932 overruns:0 frame:0
TX packets:42 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:23742351 (22.6 MiB)  TX bytes:8014 (7.8 KiB)
3. sudo service dnsmasq status output:

Code: Select all

Oct 29 22:12:16 raspberrypi dnsmasq[561]: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntr...-detect
Oct 29 22:12:16 raspberrypi dnsmasq[561]: warning: interface wlan0 does not currently exist
Oct 29 22:12:16 raspberrypi dnsmasq-dhcp[561]: DHCP, IP range 192.168.10.10 -- 192.168.10.20, lease time 12h
Oct 29 22:12:16 raspberrypi dnsmasq[561]: using nameserver 8.8.8.8#53
Oct 29 22:12:16 raspberrypi dnsmasq[561]: no servers found in /var/run/dnsmasq/resolv.conf, will retry
Oct 29 22:12:16 raspberrypi dnsmasq[561]: read /etc/hosts - 22 addresses
Oct 29 22:12:17 raspberrypi systemd[1]: Started dnsmasq - A lightweight DHCP and caching DNS server.
Oct 29 22:12:20 raspberrypi dnsmasq[561]: reading /var/run/dnsmasq/resolv.conf
Oct 29 22:12:20 raspberrypi dnsmasq[561]: using nameserver 8.8.8.8#53
Oct 29 22:12:20 raspberrypi dnsmasq[561]: using nameserver 192.168.1.1#53
Hint: Some lines were ellipsized, use -l to show in full.
4. I execute sudo ifup wlan0, and again, ifconfig output:

Code: Select all

wlan0     Link encap:Ethernet  HWaddr b8:27:eb:fe:7f:3a
inet addr:192.168.10.1  Bcast:192.168.10.255  Mask:255.255.255.0
inet6 addr: fe80::ba27:ebff:fefe:7f3a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:121311 errors:0 dropped:121311 overruns:0 frame:0
TX packets:62 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:23813280 (22.7 MiB)  TX bytes:13495 (13.1 KiB)
And sudo service dnsmasq restart, then sudo service dnsmasq status:

Code: Select all

dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
   Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled)
  Drop-In: /run/systemd/generator/dnsmasq.service.d
           └─50-dnsmasq-$named.conf, 50-insserv.conf-$named.conf
   Active: active (running) since Sun 2016-10-30 10:10:25 AEDT; 25s ago
  Process: 10283 ExecStop=/etc/init.d/dnsmasq systemd-stop-resolvconf (code=exited, status=0/SUCCESS)
  Process: 10358 ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf (code=exited, status=0/SUCCESS)
  Process: 10349 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=0/SUCCESS)
  Process: 10345 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCCESS)
 Main PID: 10357 (dnsmasq)
   CGroup: /system.slice/dnsmasq.service
           └─10357 /usr/sbin/dnsmasq -x /var/run/dnsmasq/dnsmasq.pid -u dnsmasq -r /var/run/dnsmasq/resolv.conf -7 /etc/dnsmasq.d,....

Oct 30 10:10:25 raspberrypi dnsmasq[10345]: dnsmasq: syntax check OK.
Oct 30 10:10:25 raspberrypi dnsmasq[10357]: started, version 2.72 cachesize 150
Oct 30 10:10:25 raspberrypi dnsmasq[10357]: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP connt...detect
Oct 30 10:10:25 raspberrypi dnsmasq-dhcp[10357]: DHCP, IP range 192.168.10.10 -- 192.168.10.20, lease time 12h
Oct 30 10:10:25 raspberrypi dnsmasq[10357]: using nameserver 8.8.8.8#53
Oct 30 10:10:25 raspberrypi dnsmasq[10357]: reading /var/run/dnsmasq/resolv.conf
Oct 30 10:10:25 raspberrypi dnsmasq[10357]: using nameserver 8.8.8.8#53
Oct 30 10:10:25 raspberrypi dnsmasq[10357]: using nameserver 192.168.1.1#53
Oct 30 10:10:25 raspberrypi dnsmasq[10357]: read /etc/hosts - 22 addresses
Oct 30 10:10:25 raspberrypi systemd[1]: Started dnsmasq - A lightweight DHCP and caching DNS server.
Hint: Some lines were ellipsized, use -l to show in full.
And then I can connect to the WiFi AP and access the internet.

Progress! But it seems wlan0 is not coming up at boot..?
Raspberry Pi 4 Model B | Raspberry Pi 3 Model B | Raspberry Pi 2 Model B

castletonroad
Posts: 137
Joined: Sat Jul 25, 2015 11:23 pm

[SOLVED] Re: DNSMASQ problem

Sun Oct 30, 2016 1:11 am

Code: Select all

allow-hotplug wlan0   << Unhashed this line in /etc/network/interfaces
iface wlan0 inet static
 address 192.168.10.1
 netmask 255.255.255.0
 network 192.168.10.0
 broadcast 192.168.10.255
Works a treat now.
Raspberry Pi 4 Model B | Raspberry Pi 3 Model B | Raspberry Pi 2 Model B

lbsterling
Posts: 1
Joined: Sun Apr 29, 2018 8:25 pm

Re: DNSMASQ problem

Sun Apr 29, 2018 8:31 pm

I had similar problems, but I also wanted to be able to use my wired connection on DHCP to my home network so I could SSH to the Pi from my home network without connecting to it as an access point. In /etc/network/interfaces I added:

Code: Select all

auto eth0
allow-hotplug eth0
iface eth0 inet dhcp

Return to “Troubleshooting”