On Windows, you must use WMI along with the correct search for object search properties (such as network devices). The following Python code prints IPv4 and default gateway addresses on my Windows 7 machine:
The code:
import wmi
wmi_obj = wmi.WMI()
wmi_sql = "select IPAddress,DefaultIPGateway from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE"
wmi_out = wmi_obj.query( wmi_sql )
for dev in wmi_out:
print "IPv4Address:", dev.IPAddress[0], "DefaultIPGateway:", dev.DefaultIPGateway[0]
Conclusion:
IPv4Address: 192.168.0.2 DefaultIPGateway: 192.168.0.1
WMI .
Linux PyNetInfo, , . Linux , PROC import os; os.system(...).