Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #84155

Re: Check for running DHCP daemon?

References <54C030E9.8010404@emerytelcom.com>
Date 2015-01-22 10:30 +1100
Subject Re: Check for running DHCP daemon?
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.17930.1421883026.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, Jan 22, 2015 at 10:06 AM, Jason Bailey <jbailey@emerytelcom.com> wrote:
> So I've got this python 3 script that needs to know if there is a running
> DHCP daemon (ISC DHCP server) on the local system. Is there a clean way to
> do this that (1) doesn't require me to do syscalls to local utilities (like
> ps, top, etc), and (2) doesn't require any custom modules (stock only)?

Not sure why you have these restrictions; normally I'd look at an
OS-provided status function (eg "/etc/init.d/isc-dhcp-server status",
which on my Debian system is implemented by looking for a PID file and
confirming with ps). But since DHCP uses port 67, you might be able to
use that; I don't know of a way, within your restrictions, to find out
if someone's bound to port 67, but you could send a DHCPDISCOVER
message to 127:0.0.1:67 and see if you get back an offer. That may not
be the best technique, but it could be done with just Python's
standard library. (Alternatively, if you're certain the DHCP server is
configured appropriately, you could send a DHCPREQUEST message with an
inappropriate IP and hope for a rejection.)

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Check for running DHCP daemon? Chris Angelico <rosuav@gmail.com> - 2015-01-22 10:30 +1100

csiph-web