Score:1

Speeding up apt update by changing the nameservers on Ubuntu21.10 (impish)?

au flag

I just installed Ubuntu Impish on my work laptop. I was wondering why my apt update was being so slow. After digging a bit I found that someone proposed to change the name server to have it pointed towards 8.8.8.8. After changing the /etc/resolv.conf file accordingly, magically the update was running lighting fast (as expected). My previous configuration had:

nameserver 127.0.0.53
options edns0 trust-ad
search homenet.telecomitalia.it

Does anyone have a clue on this? I really cannot understand why since I didn't change anything since installation.

cn flag
You need to ask your ISP why their DNS is slower than google's DNS ;) This is not likely to be related to the OS. Oh you can test yours here https://www.dnsperf.com/dns-speed-benchmark
Barnercart avatar
au flag
@Rinzwind Yea, it's indeed strange. I'll dig up a bit on this. But is it possible that this get falsy configured during installation? What I mean is, where does Ubuntu installation process get the nameserver from?
cn flag
When the system connects to the internet it gets this from your router and that gets it from your ISP. My router requires a unique code I got from my ISP (Ziggo) and that sets it up to their DNS. I have google as a 3rd DNS (and the 1st 2 from Ziggo).
Barnercart avatar
au flag
I looked into my router configuration page and the server DNS was indeed different from the one I had inside the configuration file. Could this be related to the fact that I used the internet connection at work during OS installation and now I'm connected to my home wifi (one ISP is Telecom and the other one is Fastweb)? I've read that usually it is recommended to set the nameserver to Google or OpenDNS anyway as a general rule. Or the IPS dns is always better even if changing location a lot?
Barnercart avatar
au flag
Also how do you setup multiple DNSs? You can just input multiple `nameserver` entries inside the `resolv.conf` file?
ru flag
@Barnercart you configure them properly in Network Manager or your Netplan files, which then feed into `systemd-resolved` which then handles DNS caching and relaying your DNS requests to 'upstream' servers. You should not directly modify the `resolv.conf` file anymore if you are using SystemD ResolveD which is the default now.
Barnercart avatar
au flag
Thanks to both. I've added and answer to summarize the matter. I found that using the `resolvconf` package was the easiest way of doing these changes persistent on multiple net interfaces. If you have a better solution using the Netplan files please share it but if I understood correctly this cannot be done globally.
Score:0
au flag

Thanks to the comments, I found out that the issue was related to an incorrect DNS Server configuration, which I could check by temporarily changing the /etc/resolv.conf file. I tested this on Ubuntu Impish (21.10) but I suppose that applies other Ubuntu releases too. You can check your real ISP DNS Server on the router page to be sure (i.e. for me it's TelecomItalia DNS).

To make this change permanent, I prefer not to use a Netplan configuration file since it cannot be used globally but needs a a separate nameservers configuration for each network interface, plus a new configuration needs to be added everytime a new wifi network comes up to the game.

I found that the easiest way is using the lightweight resolvconf package, which can be installed by:

sudo apt install resolvconf

Add the nameservers configuration to the /etc/resolv.conf file and the /etc/resolvconf/resolv.conf.d/head file first, for instance in my case:

nameserver 85.38.28.0 # Telecom DNS
nameserver 85.38.28.1 # Telecom DNS
nameserver 8.8.8.8 # Google DNS
nameserver 8.8.4.4 # Google DNS
nameserver 208.67.222.222 # OpenDNS
nameserver 208.67.222.220 # OpenDNS

Then restart the services by:

sudo systemctl restart resolvconf.service
sudo systemctl restart systemd-resolved.service

After reboot the changes should be persisted.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.