Get the IP address of WIFI interface

Tim Golden mail at timgolden.me.uk
Sun May 15 07:12:07 EDT 2011


On 15/05/2011 12:04 PM, Neal Becker wrote:
> Far.Runner wrote:
>
>> Hi python experts:
>> There are two network interfaces on my laptop: one is 100M Ethernet
>> interface, the other is wifi interface, both are connected and has an ip
>> address.
>> The question is: How to get the ip address of the wifi interface in a python
>> script without parsing the output of a shell command like "ipconfig" or
>> "ifconfig"?
>>
>> OS: Windows or Linux
>>
>> F.R
>
> Here's some useful snippits for linux:

... and for Windows:

<code>
import wmi

for nic in wmi.WMI ().Win32_NetworkAdapterConfiguration (IPEnabled=1):
   print nic.Caption, nic.IPAddress

</code>

TJG



More information about the Python-list mailing list