Best way to check if there is internet?

Grant Edwards grant.b.edwards at gmail.com
Mon Feb 7 14:40:24 EST 2022


On 2022-02-07, Dennis Lee Bieber <wlfraed at ix.netcom.com> wrote:

> Also, for a machine freshly booted, with no cache, even pinging
> Google first requires making contact with a DNS server to ask for
> Google's IP address. With no network, the DNS look-up will fail
> before ping even tries to hit Google.

Ah, c'mon... Every geek worth his salt knows a few real world IP
addresses without relying on DNS. If you want to "ping Google", it's

 $ ping 8.8.8.8
or
 $ ping 8.8.4.4

:)

If that doesn't work, then you ask 'route -n' for the IP address of
the default gateway, and try pinging that. It's possible your default
gateway is alive but configured to ignore ICMP ping requests, but I've
never run into one like that.

But, as has been pointed out previously "if there is internet" is too
vague a question to have an answer.

If all you have is proxied access to outside HTTPS servers, then I
would consider the answer to be "no", but most people would say "yes"
they have internet.

If all you have is NAT'ed outbound TCP connections, even more people
would say "yes they have internet", but I would still answer "partially".

--
Grant


More information about the Python-list mailing list