5 def get_default_gateway_linux():
6 """Read the default gateway directly from /proc."""
7 fh = open("/proc/net/route")
9 fields = line.strip().split()
10 if fields[1] != '00000000' or not int(fields[3], 16) & 2:
13 return socket.inet_ntoa(struct.pack("<L", int(fields[2], 16)))
15 print socket.getfqdn(get_default_gateway_linux())