How can I tell if my client system has a network connection using python? I can assume the client connected with DHCP. I can't use lists of known reliable sites to ping to test the connection, as it needs to work in isolated networks as well as open ones.
I thought about fetching the local ip (should work, so long as it doesn't only return loopback). But....
print socket.gethostbyaddr('localhost')
returns
('localhost', ['ip6-localhost', 'ip6-loopback'], ['::1'])
which isn't very useful. Any other ideas would be appreciated, thanks!