Python: check whether a network interface is up
The interface can be configured with an IP address and not be up so the accepted answer is wrong. You actually need to check /sys/class/net/<interface>/flags. If the content is in the variable flags, flags & 0x1 is whether the interface is up or not. Depending on the application, the /sys/class/net/<interface>/operstate might be what you really … Read more