How to list network interfaces, its configuration IP,netmask and gateway in Python/Windows

11,369

Solution 1

Not sure exactly what info you want, but ipconfig /all certainly sounds like what you want:

import subprocess
subprocess.call('ipconfig /all')

Solution 2

For a cross platform solution, I've used netifaces.

Share:
11,369
ntcong
Author by

ntcong

"

Updated on June 05, 2022

Comments

  • ntcong
    ntcong almost 2 years

    I wanna develop a small application to monitor arp and scan arp list in local network.

    Currently, I need to retrieve the list of network interfaces and its configuration.

    Most of the time I work with Linux, so I don't know much about Win32 API, is there anyway to do this in python way ? I'm using Python 2.6 with PyQt and Scapy (has pywin32 aswell, so if you provide the detail way with win32, I will try)

    I found pcapy.findalldevs(), but it cannot retrive configuration. I don't care much about the name, just configuration(IP,netmask) is OK.