These are the outputs I get when I type:

 systemctl status dnsmasq

 ● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2017-12-14 08:49:31 UTC; 54min ago
Process: 590 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=2)
Process: 569 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCCESS)

Dec 14 08:49:30 raspberrypi systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server...
Dec 14 08:49:30 raspberrypi dnsmasq[569]: dnsmasq: syntax check OK.
Dec 14 08:49:31 raspberrypi dnsmasq[590]: dnsmasq: failed to create listening socket for 10.0.20.1: Cannot assign requested address
Dec 14 08:49:31 raspberrypi systemd[1]: dnsmasq.service: Control process exited, code=exited status=2
Dec 14 08:49:31 raspberrypi systemd[1]: Failed to start dnsmasq - A lightweight DHCP and caching DNS server.
Dec 14 08:49:31 raspberrypi systemd[1]: dnsmasq.service: Unit entered failed state.
Dec 14 08:49:31 raspberrypi systemd[1]: dnsmasq.service: Failed with result 'exit-code'.

It works fine when I start the service manually.

I have set a static ip like this:

sudo nano /etc/dhcpcd.conf


interface wlan0
static ip_address=10.0.20.1/24
static routers=10.0.20.0
  • The log files should give you more information as to what may be going wrong. – Raman Sailopal Dec 14 '17 at 10:08
  • 2
    The log clearly says: you don't have ip 10.0.20.1 on your interfaces. – Ipor Sircer Dec 14 '17 at 10:26
  • It was a typo there.I had corrected it. – athul Dec 14 '17 at 11:53
Dec 14 08:49:31 raspberrypi dnsmasq[590]: dnsmasq: failed to create listening socket for 10.0.20.1: Cannot assign requested address

This line indicates that your machine does not have the address 10.0.20.1 on your system when dnsmasq starts up. You need to reconfigure the systemd unit to start after this address has been added. This can be done by using systemd drop-ins. Create the directory /etc/systemd/system/dnsmasq.service.d and the add the following to a file with a .conf extension in that directory:

[Unit]
After=network-online.target

This assumes that your network is being brought online in a usual manner, and that it falls under the network-online.target unit. If it does not then this will not work and you'll need to adjust accordingly.

  • I tried but it's not working still the result is same.I am using it in raspberry pi with raspbian stretch lite. "Afer" had "network.target" in /lib/systemd/system/dnsmasq.service .I have edited it there and not as you said in the /etc/systemd/system/dnsmasq.service.d .Hope that too is fine. – athul Dec 15 '17 at 6:27
up vote 0 down vote accepted

I solved the issue

I removed giving ip like this

sudo nano /etc/dhcpcd.conf


interface wlan0
static ip_address=10.0.20.1/24
static routers=10.0.20.0

And I gave ip to interfaces like this.

 sudo nano /etc/network/interfaces


 # interfaces(5) file used by ifup(8) and ifdown(8)

 # Please note that this file is written to be used with dhcpcd
 # For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

 # Include files from /etc/network/interfaces.d:
 source-directory /etc/network/interfaces.d

 auto wlan0
 iface wlan0 inet static
 address 10.0.20.1
 netmask 255.255.255.0

 auto eth0
 iface eth0 inet dhcp

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.