You are not logged in.

#1 2012-12-09 16:15:36

ungoliant
Member
Registered: 2009-05-17
Posts: 39

dnsmasq service shutting down after a while

Hi guys,

I'm working on the organization crew of a LAN party we are holding up in Las Palmas, and we are testing dnsmasq service to provice DHCP and DNS cache within the LAN. Everything works OK after I boot up the server: shorewall provides routing and dnsmasq gives IP's and resolves DNS queries... but after some minutes, dnsmasq shuts down:

[root@ion6router multi-user.target.wants]# systemctl status dnsmasq.service 
dnsmasq.service - A lightweight DHCP and caching DNS server
	  Loaded: loaded (/usr/lib/systemd/system/dnsmasq.service; enabled)
	  Active: failed (Result: timeout) since dom, 2012-12-09 16:01:21 WET; 9s ago
	    Docs: man:dnsmasq(8)
	 Process: 748 ExecStartPre=/usr/bin/dnsmasq --test (code=exited, status=0/SUCCESS)
	Main PID: 751
	  CGroup: name=systemd:/system/dnsmasq.service

dic 09 15:59:51 ion6router dnsmasq[751]: started, version 2.64 cachesize 150
dic 09 15:59:51 ion6router dnsmasq[751]: compile time options: IPv6 GNU-getopt DBus no-i18n no-IDN DHCP DHCPv6 no-Lua TFTP no-conntrack
dic 09 15:59:51 ion6router dnsmasq[751]: DBus support enabled: connected to system bus
dic 09 15:59:51 ion6router dnsmasq-dhcp[751]: DHCP, IP range 172.16.0.50 -- 172.16.3.254, lease time 12h
dic 09 15:59:51 ion6router dnsmasq[751]: reading /etc/resolv.conf
dic 09 15:59:51 ion6router dnsmasq[751]: using nameserver 194.224.52.6#53
dic 09 15:59:51 ion6router dnsmasq[751]: using nameserver 194.224.52.4#53
dic 09 15:59:51 ion6router dnsmasq[751]: read /etc/hosts - 3 addresses
dic 09 16:01:21 ion6router systemd[1]: Failed to start A lightweight DHCP and caching DNS server.
dic 09 16:01:21 ion6router systemd[1]: Unit dnsmasq.service entered failed state

If I try to start dnsmasq, it fails after 3 o 4 minutes (In those minutes, the service actually works)

[root@ion6router multi-user.target.wants]# systemctl start dnsmasq.service 
Job for dnsmasq.service failed. See 'systemctl status dnsmasq.service' and 'journalctl -xn' for details.

Any idea on what could be happening?

Thanks in advance.

Offline

#2 2012-12-09 16:29:25

ungoliant
Member
Registered: 2009-05-17
Posts: 39

Re: dnsmasq service shutting down after a while

More info: its seems that if I use the old initscripts method (/etc/rc.d/dnsmasq start), it doesnt shut down, or at least it hasn't yet.

Offline

#3 2012-12-11 11:34:39

blackrebel
Member
Registered: 2012-12-10
Posts: 5

Re: dnsmasq service shutting down after a while

Hi, i think it's dbus related. Systemd starts dnsmasq with dbus, the rc script doesn't.
I have this problem too, so several service depends to dbus appear to not starting or in failed state.
Polkit results 'dead' and systemd-logind trying to start and fail after a minute and so on.
If you restart dbus, all problems go away and every of this service starts without problem.
The problem imho is dbus.

Offline

#4 2012-12-12 16:42:21

Leonid.I
Member
From: Aethyr
Registered: 2009-03-22
Posts: 999

Re: dnsmasq service shutting down after a while

@ungoliant:
Is this still an issue? I'll test a setup similar to yours over the weekend, but in the meantime some quick thoughts...

The only difference between rc.d and service file is that in the former dnsmasq starts backgrounded while in the latter it runs in the foreground (-k). So, what happens if you run manually the service file?

# dnsmasq --test
# echo $?
# dnsmasq -k --enable-dbus --user=dnsmasq --pid-file

Also if you suspect dbus (although I don't see how it can cause problems), try disabling it and running service as Type=forking

/etc/systemd/system/dnsmasq-service

[Unit]
Description=A lightweight DHCP and caching DNS server
After=network.target
Documentation=man:dnsmasq(8)

[Service]
Type=forking
PIDFile=/run/dnsmasq.pid
ExecStart=/usr/bin/dnsmasq --user=dnsmasq --pid-file=/run/dnsmasq.pid
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target

This will emulate the rc.d script and should work but I'd still try to investigate the problem with the stock dnsmasq.service.


Arch Linux is more than just GNU/Linux -- it's an adventure
pkill -9 systemd

Offline

#5 2012-12-20 02:35:48

Leonid.I
Member
From: Aethyr
Registered: 2009-03-22
Posts: 999

Re: dnsmasq service shutting down after a while

@ungoliant:
I can't reproduce your issue... 5+ hours of uptime on a server and dnsmasq still gives out IPs...


Arch Linux is more than just GNU/Linux -- it's an adventure
pkill -9 systemd

Offline

#6 2012-12-20 10:49:25

glemt9
Member
From: Slovenija
Registered: 2011-11-28
Posts: 10
Website

Re: dnsmasq service shutting down after a while

I can also confirm that dnsmasq and other custom services are working only with: Type=forking.

Offline

#7 2012-12-20 15:56:00

Leonid.I
Member
From: Aethyr
Registered: 2009-03-22
Posts: 999

Re: dnsmasq service shutting down after a while

glemt9 wrote:

I can also confirm that dnsmasq and other custom services are working only with: Type=forking.

I am afraid you didn't understand my previous post. I was talking about the stock dnsmasq.service which has been working on my router for about 1 day now:

% cat /etc/systemd/system/dnsmasq.service
[Unit]
Description=A lightweight DHCP and caching DNS server
After=network.target
Documentation=man:dnsmasq(8)

[Service]
Type=dbus
BusName=uk.org.thekelleys.dnsmasq
ExecStartPre=/usr/bin/dnsmasq --test
ExecStart=/usr/bin/dnsmasq -k --enable-dbus --user=dnsmasq --pid-file --stop-dns-rebind
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target
Alias=dbus-uk.org.thekelleys.dnsmasq

and

% systemctl status dnsmasq.service 
dnsmasq.service - A lightweight DHCP and caching DNS server
	  Loaded: loaded (/etc/systemd/system/dnsmasq.service; enabled)
	  Active: active (running) since Wed, 2012-12-19 15:51:15 EST; 19h ago
	    Docs: man:dnsmasq(8)
	 Process: 398 ExecStartPre=/usr/bin/dnsmasq --test (code=exited, status=0/SUCCESS)
	Main PID: 409 (dnsmasq)
	  CGroup: name=systemd:/system/dnsmasq.service
		  └─409 /usr/bin/dnsmasq -k --enable-dbus --user=dnsmasq --pid-file --stop-dns-rebind

EDIT: Do you guys have the dbus up and running, like this

% ps auxww | gr -m 1 dbus
dbus       319  0.0  0.0  17408  1544 ?        Ss   Dec19   0:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation

Last edited by Leonid.I (2012-12-20 15:59:11)


Arch Linux is more than just GNU/Linux -- it's an adventure
pkill -9 systemd

Offline

#8 2012-12-20 16:30:54

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: dnsmasq service shutting down after a while

I suspect that "after a while" coincides with dbus package updates.

Last edited by falconindy (2012-12-21 14:47:22)

Offline

#9 2013-01-03 19:35:32

glemt9
Member
From: Slovenija
Registered: 2011-11-28
Posts: 10
Website

Re: dnsmasq service shutting down after a while

Leonid.I wrote:

EDIT: Do you guys have the dbus up and running, like this

% ps auxww | gr -m 1 dbus
dbus       319  0.0  0.0  17408  1544 ?        Ss   Dec19   0:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation

Mine is a little different:

$ ps auxww | grep -m 1 dbus
my_user_name     578  0.0  0.0  17444  1068 ?        Ss   Jan02   0:00 /usr/bin/dbus-daemon --fork --print-pid 4 --print-address 6 --session

Offline

#10 2013-01-03 23:18:56

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: dnsmasq service shutting down after a while

That's because you're looking at the session bus and not the system bus.

Offline

#11 2013-01-04 07:52:32

blackrebel
Member
Registered: 2012-12-10
Posts: 5

Re: dnsmasq service shutting down after a while

blackrebel wrote:

Hi, i think it's dbus related. Systemd starts dnsmasq with dbus, the rc script doesn't.
I have this problem too, so several service depends to dbus appear to not starting or in failed state.
Polkit results 'dead' and systemd-logind trying to start and fail after a minute and so on.
If you restart dbus, all problems go away and every of this service starts without problem.
The problem imho is dbus.

Ok, i find the way. My problem was openldap that starts too late and 'a lot of time' after dbus, so it (dbus) can't connect to ldap server. Some service (dnsmasq and other) return in failed state because can't connect/authenticate with ldap service. The solution for me is to use nslcd, with nss-pam-ldapd package from AUR. This pkg replace nss_ldap and pam_ldap from official repo.

Offline

#12 2013-01-10 09:21:23

glemt9
Member
From: Slovenija
Registered: 2011-11-28
Posts: 10
Website

Re: dnsmasq service shutting down after a while

falconindy wrote:

That's because you're looking at the session bus and not the system bus.

Sorry u'r right...

dbus       992  0.0  0.0  17300  1164 ?        Ss   Jan08   0:06 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation

Offline

#13 2013-03-15 12:26:36

glemt9
Member
From: Slovenija
Registered: 2011-11-28
Posts: 10
Website

Re: dnsmasq service shutting down after a while

And sometimes is good to check if /var/run is symlinked to /run big_smile instead of being directory.

Offline

Board footer

Powered by FluxBB