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.
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 22.214.171.124... * TCP_NODELAY set * connect to 126.96.36.199 port 80 failed: Connection timed out * Trying 188.8.131.52... * TCP_NODELAY set * Connected to connectivity-check.ubuntu.com (184.108.40.206) 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!
How timely! This happens on a regular basis to me, but I always thought it was because of a poorly configured WAP that I haven’t had time to optimize.
For sure try it out! I like this solution b/c I don’t lose any functionality.
Justin, do you know of a way to _check_ to see if the is actually being used? I _think_ I did it, but I can’t seem to find a command that shows what .conf files are currently loaded.
Thanks in advance for any light you can shed.
Yeah, you can see the journal logs from your last boot with
journalctl -b --utc. In there I see these lines:
Feb 01 21:52:32 DesertEagle13 NetworkManager:
[1612216352.0901] Read config: /etc/NetworkManager/NetworkManager.conf
(lib: 10-dns-resolved.conf, 20-connectivity-ubuntu.conf, no-mac-addr-change.conf)
(etc: 10-globally-managed-devices.conf, 10-ubuntu-fan.conf,11-connectivity.conf, default-wifi-powersave-on.conf)
The custom connectivity settings will override the distribution provided ones.
I totally understand if you don’t have time for this (you can just say so :-), but I’m not finding it. I’ve confirmed that the text in the file is correct, and that the file is in the correct place. After shortening the vacuum time to 7 days (do I need more? I wouldn’t know 🙂 I’m getting about 2500 lines in the journal query, so I copy and paste them into a text editor so I can search, but I’m not finding any matches.
I do see the following two lines repeated 3 times throughout the log, however:
req:3 ‘connectivity-change’: new request (1 scripts)
eq:3 ‘connectivity-change’: start running ordered scripts…
Can you see anything obvious that I’m doing wrong?
journalctlwill spit out a TON of lines. I suggest doing
journalctl -bwhich will get you just the messages since last boot. I found that line using grep to look for the filename:
journalctl -b | grep '11-connectivity'