I wrote earlier about how I had to do some configuration of my DNS to get dnsmasq and resolved to work well together. With it working well I’m able to use dnsmasq, resolved, and network manager together to do local development while also detecting network changes nicely.
Recently I noticed I would occasionally get the dreaded question-mark network icon: “?” I did some digging around and it was related to Ubuntu’s Network Connectivity check. Several posts out there simply say to disable the check by going to Settings -> Privacy and turning Connectivity Checking to “Off.”
But by disabling connectivity checking, I don’t get the automatic prompt to connect through a captive portal (like at my local library). I wanted to actually fix the problem, so I needed to understand what the problem was.Continue reading
Ubuntu uses the URL http://connectivity-check.ubuntu.com/ by default for connectivity checking. I went to the command line to see if there were any problems using
curl while on my wired network:
$ curl -v http://connectivity-check.ubuntu.com/ * Trying 220.127.116.11... * TCP_NODELAY set * connect to 18.104.22.168 port 80 failed: Connection timed out * Trying 22.214.171.124... * TCP_NODELAY set * Connected to connectivity-check.ubuntu.com (126.96.36.199) port 80 (#0) > GET / HTTP/1.1 > Host: connectivity-check.ubuntu.com > User-Agent: curl/7.58.0 > Accept: */* > < HTTP/1.1 204 No Content < Date: Wed, 09 Dec 2020 16:02:34 GMT < Server: Apache/2.4.18 (Ubuntu) < X-NetworkManager-Status: online < * Connection #0 to host connectivity-check.ubuntu.com left intact
Everything seemed to work out in the end, but you can see that the first request failed so it had to fall back to the secondary address. This whole request took 122 seconds.
The problem is, the default connectivity check interval is 120 seconds. So after the first one times out Network Manager flags the computer as offline. Apps like Spotify recognize the offline network status and stop working – despite being actually connected to the internet.
I could roll-my-own Network Manager connectivity endpoint – but I found an easier solution: use the default Debian endpoint.
The Debian default URL is http://network-test.debian.org/nm which has 3 IPs listed (for fall back) and it is much faster. All I had to do was add this file:
sudo vi /etc/NetworkManager/conf.d/11-connectivity.conf
[connectivity] uri=http://network-test.debian.org/nm interval=300
I gave it a little longer interval – 5 minutes instead of 2. It’s probably not necessary as their service responds much faster, but I want to avoid the question-mark-of-no-connectivity as much as possible but still retain features like captive portal detection.
Restart after you’ve saved that file and you should be good to go!