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


Groups > comp.lang.python > #84155 > unrolled thread

Re: Check for running DHCP daemon?

Started byChris Angelico <rosuav@gmail.com>
First post2015-01-22 10:30 +1100
Last post2015-01-22 10:30 +1100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#84155 — Re: Check for running DHCP daemon?

FromChris Angelico <rosuav@gmail.com>
Date2015-01-22 10:30 +1100
SubjectRe: Check for running DHCP daemon?
Message-ID<mailman.17930.1421883026.18130.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web