some applications hang for up to 30sec due to /run/systemd/resolve/io.systemd.Resolve
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
systemd (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
I just installed Ubuntu-22.04 last week and have noticed lots of command line apps seem to hang for 10-30sec before working. Eventually that got annoying enough that I looked into it.
Anyway, apps like "telnet" (yep, I'm that old) and oddly enough sudo showed this issue strongly. In the end I ran them with strace and could see the pause occurred when /run/systemd/
Then I cranked up "tcpdump -n -i any port 53" and re-ran the commands. What I found was systemd-resolver was throwing DNS lookups for my hostname at all the DNS servers I had configured (default on wifi plus corporate always-on VPN link). Now the thing is our corporate VPN has SIXTEEN domains in the search domain field... So as systemd-resolver was doing one "A" plus one "AAAA" lookups for each "hostname.
To fix it I simply added my raw (ie non-dot) hostname to /etc/hosts - completely blocked this self-hostname lookup that must be going on. Now there are no DNS lookups at all for my hostname in this situation.
All is good. But it does make me wonder if perhaps Ubuntu shouldn't always put the hostname into /etc/hosts? Even pointing at 127.0.0.99 (for example) might be enough (I haven't actually tested that - I'm pointing it at my static VPN IP)
Anyway, this is a corner case for sure - but it might shave some delays off a bunch of folks. This also might seem cosmetic, but I would guess any application that calls gethostbyname or equivalent on itself is triggering this.
PS: I had Ubuntu-20.04 before this and didn't have the problem. But looking at a backup I can see I also had my hostname in the /etc/hosts file - so this might have affected 20.04 too but I "accidentally" fixed it early on without realizing it