I've got a system - accessible over local network but not connected to the internet. I'm facing issues when changing the hostname of this system. I know that changing hostname is a two step process:
- hostnamectl set-hostname myhost.mydomain
- sudo nano /etc/hosts -------> It takes ages to open the file/execute any command using sudo
When the command does execute, I get the usual
sudo: unable to resolve host myhost.mydomain: Name or service not known
The issue is the delay in sudo command that occurs. I can change hostnames using the above two step process on devices connected to other network easily (without observing the noticeable delay in the sudo command). It is only devices connected to this network that I'm facing the sudo delay issue.
Some more experiments - When I reverse the order of changing hostnames, i.e.
- sudo nano /etc/hosts - # append myhost.mydomain
- hostnamectl set-hostname myhost.mydomain
Everything works perfectly fine and no sudo delay issues are observed. This has led (or misled) me to believe that there might be some issues with DNS resolution. But apart from this I cannot make out why this delay is observed on this system on this specific network.
I've checked the logs of systemd-hostnamed service as well before and after setting hostname and there are no errors observed.
Please let me know how can debug this more effectively
sudo
perform a lookup for the hostname? I have not encountered this issue on Ubuntu.