Check for running DHCP daemon?

sohcahtoa82 at gmail.com sohcahtoa82 at gmail.com
Fri Jan 23 17:38:42 EST 2015


On Friday, January 23, 2015 at 2:07:04 PM UTC-8, Jason Bailey wrote:
> Is there a way to do it without calling external utilities (i.e. a 
> Python module, etc)? I'd rather stay within the realm of Python if possible.
> 
> Jason
> 
> 
> 
> On 01/23/2015 10:04 AM, Chris Angelico wrote:
> > On Sat, Jan 24, 2015 at 3:02 AM, Jason Bailey <jbailey at emerytelcom.com> wrote:
> >> I'm actually wondering if it might be more beneficial for me to check if the
> >> local DHCP port (udp 67) is bound and in use. I had tried to do this some
> >> time ago, and couldn't get it working right (it would always test true, even
> >> when it shouldn't have). Can anyone steer me in the right direction on port
> >> status?
> > You can check with netstat:
> >
> > $ sudo netstat -n4lp|grep ':67 '
> > udp        0      0 0.0.0.0:67              0.0.0.0:*
> >           22466/dhcpd
> >
> > On my system, there's a /proc/net/udp which carries this information.
> > Everything's in hex, so port 67 is shown as 0043:
> >
> > $ grep :0043 /proc/net/udp
> >   5755: 00000000:0043 00000000:0000 07 00000000:00000000 00:00000000
> > 00000000     0        0 8334454 2 ffff880403e60b40 0
> >
> > You'd have to check your own system to know what's truly reliable and
> > worth using.
> >
> > ChrisA

First off, don't top post.  Either use the interleaved or bottom-posting style.  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

Secondly, even if you find a module, keep in mind that the module probably won't stay in Python land.  It will probably call an external utility itself.

If you REALLY wanted to check it without calling an external utility, you could connect to port 67 and see what happens, but that could cause problems.



More information about the Python-list mailing list