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


Groups > comp.lang.python > #84155

Re: Check for running DHCP daemon?

Path csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.079
X-Spam-Evidence '*H*': 0.84; '*S*': 0.00; '22,': 0.09; 'cc:addr :python-list': 0.11; 'python': 0.11; 'jan': 0.12; '67,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; "someone's": 0.16; 'status",': 0.16; 'wrote:': 0.18; 'normally': 0.19; "python's": 0.19; 'thu,': 0.19; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; "i've": 0.25; 'script': 0.25; 'certain': 0.27; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; "doesn't": 0.30; '(like': 0.30; 'message- id:@mail.gmail.com': 0.30; 'file': 0.32; 'running': 0.33; 'implemented': 0.33; "i'd": 0.34; 'could': 0.34; '(2)': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'library.': 0.36; 'done': 0.36; 'subject:?': 0.36; 'server': 0.38; 'configured': 0.38; 'jason': 0.38; 'sure': 0.39; 'system.': 0.39; 'hope': 0.61; "you're": 0.61; 'back': 0.62; 'within': 0.65; 'offer.': 0.74; '2015': 0.84; 'bailey': 0.84; 'confirming': 0.84; 'dhcp': 0.84; 'etc),': 0.84; 'to:none': 0.92; 'subject:Check': 0.95
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=giw+vLyW8XuC95M10Yk2ua40g/HaKAwTTGUV7gL8Fq8=; b=qvXih/1hMV7KI2Xoq7aFcoV+JACwgy/lcURjx7IBELO/ZHaJhXxQhOwgxhktUocufE 5VZjqk0faVghAiZhvvSVmCauOlwD9hCt5JJ7PCL12J7WvLx3UEtrEKeaTjIMvKaQt21V 19I83FrXBoF+2kr/+zKzLFwaAWcj91RN3/8NGgZ0Pw46fdPSC/a/9wpa8nZFXjfYXcoj 7M3BrlRfE9bRPpqetPpL7nj8FsA+nCBOEL4yYxmOM+E8tj1Yx7IwMU8T1aSTdlqdnadC BbE+whlULy3UEyi2QgAkPINrmoAuz+4bMuIobl2apJuHEcbEncRnAfwAbii7C2HxrMvO Xd9A==
MIME-Version 1.0
X-Received by 10.140.21.229 with SMTP id 92mr59395404qgl.33.1421883022530; Wed, 21 Jan 2015 15:30:22 -0800 (PST)
In-Reply-To <54C030E9.8010404@emerytelcom.com>
References <54C030E9.8010404@emerytelcom.com>
Date Thu, 22 Jan 2015 10:30:22 +1100
Subject Re: Check for running DHCP daemon?
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.17930.1421883026.18130.python-list@python.org> (permalink)
Lines 19
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1421883026 news.xs4all.nl 2869 [2001:888:2000:d::a6]:43652
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:84155

Show key headers only | 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