pimoroni / unicorn-hat

Python library for Unicorn pHAT and HAT. 32 or 64 blinding ws2812 pixels for your Raspberry Pi
https://shop.pimoroni.com/products/unicorn-hat
MIT License
370 stars 131 forks source link

8.8.8.8 is blocked by my ISP, www.google.com works fine #132

Closed nigels-com closed 4 years ago

nigels-com commented 5 years ago

The installer is pinging 8.8.8.8 to check internet connectivity. However, my ISP appears to be blocking that address for DNS purposes.

$ ping -q -w 10 -c 1 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.

--- 8.8.8.8 ping statistics ---
3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 2074ms
pipe 3

Changing the script to www.google.com as a workaround works:

$ ping -q -w 10 -c 1 www.google.com
PING www.google.com (172.217.167.68) 56(84) bytes of data.

--- www.google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 16.286/16.286/16.286/0.000 ms
Gadgetoid commented 5 years ago

Yikes. This is the first I've heard of an isp blocking 8.8.8.8. Usually it's a user choice to rid themselves of Google's watchful eye.

Thinking out loud, since I think there's a more significant change that needs to happen here -

I honestly wonder if we need this check at all, since it's very possible for this particular test to pass while fetching package lists or packages from apt will fail due to firewall constraints.

It might be worth instead running an apt update and checking the status, since we almost always do that later in the script without error trapping anyway.

nigels-com commented 5 years ago

My guess is that Exetel blocked to this due to potential performance concerns. (Australia to North America or Europe is laggy) . I don't agree with with it, but I'm entirely happy with their service aside from this particular quirk.

If I recall correctly I ran into the same issue installing the Blinkt! Python stuff as well.

Pyroseza commented 5 years ago

what about pinging 1.1.1.1? That's a much better one to ping is it not?

Gadgetoid commented 4 years ago

@Pyroseza will give that a try and see how many complaints I get, thanks 😆

Pyroseza commented 4 years ago

Lol! Nice one Phil, can't believe it's been open this long! Should not have any issues with 1.1.1.1, after all it's CloudFlare 🤣

Gadgetoid commented 4 years ago

Well- yeah- when CloudFlare is down the internet is technically down too 🙄

henrym9 commented 4 years ago

Heya folks, I've got to complain about the opposite problem. My ISP in Chile uses 1.1.1.1 for some of their internal stuff despite being notified that that's not an acceptable practice, but the end result is that it is blocked. I've had to give up on using Cloudflare's DNS service (their CDN works fine), but 8.8.8.8 and 8.8.4.4 are our only options.

Gadgetoid commented 4 years ago

Apparently this is a difficult problem!

In the long term, better exception handling might be the sensible alternative to trying to check connectivity beforehand- since even a working connection might not indicate that apt, or any other commands will work.

In the short term, perhaps a test that fails over from 1.1.1.1 to 8.8.8.8 and fails outright if neither respond would satisfy most cases.

Gadgetoid commented 4 years ago

Something like the following should- in theory- satisfy both cases:

check_network() {
        sudo ping -q -w 10 -c 1 1.1.1.1 | grep "received, 0" &> /dev/null
        if [ $? -eq 0 ]; then
                return 0
        else
                sudo ping -q -w 10 -c 1 8.8.8.8 | grep "received, 0" &> /dev/null
                if [ $? -eq 0 ]; then
                        return 0
                fi
        fi
        return 1
}
henrym9 commented 4 years ago

Maybe pinging github.com? If that doesn't work, it indicates either no DNS, or no connectivity to the site you'll be pulling from; either way that would be a fatal error, right?