LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   rc.dhcpd has an odd error. (https://www.linuxquestions.org/questions/slackware-14/rc-dhcpd-has-an-odd-error-4175730379/)

Richard Cranium 10-29-2023 09:29 PM

rc.dhcpd has an odd error.
 
This hasn't come up because who the devil restarts their dhcpd while the system is running? (At least that's my story and I'm sticking to it.)

It turns out I've been doing that while attempting to fix a dynamic DNS issue. The issue comes about because the dhcpd binary looks for the pid file and won't start if it finds one.

For example, the first time you run restart:

Code:

root@testbed:~# /etc/rc.d/rc.dhcpd restart
Shutting down dhcpd:
Starting dhcpd:  /usr/sbin/dhcpd  Internet Systems Consortium DHCP Server 4.4.3-P1
Copyright 2004-2022 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Config file: /etc/dhcpd.conf
Database file: /var/state/dhcp/dhcpd.leases
PID file: /var/run/dhcpd.pid
There's already a DHCP server running.

If you think you have received this message due to a bug rather
than a configuration issue please read the section on submitting
bugs on either our web page at www.isc.org or in the README file
before submitting a bug.  These pages explain the proper
process and the information we find helpful for debugging.

exiting.

root@testbed:~#

...but the second time you run that command, you get...

Code:

root@testbed:~# /etc/rc.d/rc.dhcpd restart
Shutting down dhcpd: dhcpd: no process found

Starting dhcpd:  /usr/sbin/dhcpd  Internet Systems Consortium DHCP Server 4.4.3-P1
Copyright 2004-2022 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Config file: /etc/dhcpd.conf
Database file: /var/state/dhcp/dhcpd.leases
PID file: /var/run/dhcpd.pid
Wrote 0 deleted host decls to leases file.
Wrote 0 new dynamic host decls to leases file.
Wrote 1 leases to leases file.
Listening on LPF/virbr0/52:54:00:0a:3c:64/192.168.122.0/24
Sending on  LPF/virbr0/52:54:00:0a:3c:64/192.168.122.0/24
Listening on LPF/eth0/b4:2e:99:4c:f8:21/10.10.0.0/24
Sending on  LPF/eth0/b4:2e:99:4c:f8:21/10.10.0.0/24
Listening on LPF/eth1/00:13:3b:0e:d0:9e/172.16.0.0/24
Sending on  LPF/eth1/00:13:3b:0e:d0:9e/172.16.0.0/24
Sending on  Socket/fallback/fallback-net

root@testbed:~#

There are a couple of ways to fix the issue:
  1. You can make "--no-pid" a default DHCPD_OPTIONS value, so there won't be a pid file to check
  2. You can add "rm /var/run/dhcpd.pid" in the stop() block

I don't have an opinion upon which option is superior. The stop() bit of the script doesn't bother to look at /var/run/dhcpd.pid but instead just kills everything named dhcpd.

Richard Cranium 10-29-2023 11:18 PM

Derp. That's running Slackware64 15.0 that's up-to-date as of 4:40AM CDT this morning.

gus3 10-30-2023 12:33 PM

My first step is, trace it with
Code:

sh -vx /etc/rc.d/rc.dhcpd restart

Richard Cranium 11-01-2023 09:01 PM

Quote:

Originally Posted by gus3 (Post 6461795)
My first step is, trace it with
Code:

sh -vx /etc/rc.d/rc.httpd restart

Maybe you replied to the wrong thread; I know what the problem is.

pan64 11-02-2023 04:13 AM

When you want to stop a service:
if the process/service is not running (stopped already) nothing will happen, therefore the pidfile will not be checked and removed.
if the process/service is running it should be terminated and also the pidfile(s) should be removed.

An existing pidfile without running process means incorrect termination or a bug in the software somewhere. The fix is: remove the pidfile manually or find/fix/report the bug. Don't add --no-pid as it will probably make things worse (because the pidfile is still there).
And I wouldn't add force remove to the stop function (it looks like an ugly workaround for me), but I would rather try to terminate it properly.

GazL 11-02-2023 04:14 AM

I don't use network-manager and I replaced slackware's stock networking scripts with my own, but I find dhcpcd manages its pidfiles itself if you issue the 'dhcpcd -k' or 'dhcpcd -x' commands to stop it.

One caveat is that the pidfile name used is somewhat dynamic and can change depending on what options were provided to dhcpcd when you started it: 'dhcpcd -P' can help with that though.

Petri Kaukasoina 11-02-2023 07:57 AM

Quote:

Originally Posted by Richard Cranium (Post 6461688)
Code:

root@testbed:~# /etc/rc.d/rc.dhcpd restart

Quote:

Originally Posted by gus3 (Post 6461795)
Code:

sh -vx /etc/rc.d/rc.httpd restart

Quote:

Originally Posted by GazL (Post 6462320)
'dhcpcd -k' or 'dhcpcd -x'.

dhcpcd != dhcpd != httpd

gus3 11-02-2023 10:32 AM

Quote:

Originally Posted by Petri Kaukasoina (Post 6462345)
dhcpcd != dhcpd != httpd

:doh: :redface: :banghead: That was my (really stupid) goof.

But my suggestion remains. Running "sh -vx /etc/rc.d/rc.[service]" in that directory, to examine what's going on, is the best place to start. It might be simple timing, so a simple fix; or maybe something worse, especially when it's wrong or suspicious. But the first step is to gather that extra, unusual information.

GazL 11-02-2023 11:21 AM

Quote:

Originally Posted by Petri Kaukasoina (Post 6462345)
dhcpcd != dhcpd

Oops! :redface:

Petri Kaukasoina 11-02-2023 12:14 PM

By the way, there is actually no /etc/rc.d/rc.dhcpd in Slackware. You have probably copied it from usb-and-pxe-installers/README_PXE.TXT like I did when I used PXE to install Slackware.

I noticed this in https://www.isc.org/dhcp/:
Quote:

ISC has announced the end of maintenance for ISC DHCP as of the end of 2022. ISC will continue providing professional support services for existing subscribers, but does not intend to issue any further maintenance releases. For resources that may help in migrating your existing ISC DHCP server deployment to our newer DHCP server, Kea, please ...
This is the new one: https://www.isc.org/download/#Kea
In slackbuilds.org: https://slackbuilds.org/repository/15.0/network/kea/

Richard Cranium 11-03-2023 07:38 PM

Quote:

Originally Posted by Petri Kaukasoina (Post 6462391)
By the way, there is actually no /etc/rc.d/rc.dhcpd in Slackware. You have probably copied it from usb-and-pxe-installers/README_PXE.TXT like I did when I used PXE to install Slackware.

I noticed this in https://www.isc.org/dhcp/:

This is the new one: https://www.isc.org/download/#Kea
In slackbuilds.org: https://slackbuilds.org/repository/15.0/network/kea/

You are absolutely correct about rc.dhcpd. I guess I pulled it in a loooong time ago on one of my Slackware machines and cloned it to the others I run.

The tell (had I been paying attention) would have been that it was launched via rc.local versus a block in rc.M.

I've never done a real PXE boot on my networks (I did look at it more than a decade ago), so I probably pulled rc.dhcpd out of one of the /usr/doc/ files that had it.

(I hadn't looked for kea in slackbuilds.org; I rather assumed that Slackware itself would pull that in. For all I know, it's in -current.)

Thank you very much, Petri Kaukasoina, for clarity. I apologize for the noise here.

HQuest 11-06-2023 12:13 PM

1 Attachment(s)
Quote:

Originally Posted by Richard Cranium (Post 6461688)
who the devil restarts their dhcpd while the system is running?

Me reading this thread:


All times are GMT -5. The time now is 10:58 PM.