How do I send a DHCP request to find DHCP server IP address? Is this possible?
<p>Is it possible to write a small script that will send out a DHCP broadcast request and find the DHCP server address?</p>

<p>I need this for a project, but my research led me to believe that you cannot do this on Windows? I would need a small script for OSX, Linux and Windows. </p>

<p>Okay, I'm going to make the assumption that your default gateway is configured to point at your DHCP server. I found the following package and was able to get my default gateway:</p>

<pre><code>#!/usr/bin/env python
import netifaces

gateway_info = netifaces.gateways()
print(gateway_info)
</code></pre>

<p>I of course first had to install the <code>netifaces</code> module via pip:</p>

<p>$> pip install --user netifaces</p>

<p>Code returns the following:</p>

<p>$> ./test3.py </p>

<p>{'default': {2: ('192.168.0.1', 'en0')}, 2: [('192.168.0.1', 'en0', True)]}</p>

<p>I hope this helps.</p>

<p>Best regards,</p>

<p>Aaron C.</p>

python dhcp