I am setting up a new home server with Ubuntu 16.04 as its OS. I use SSH to access the server for setup. When I SSH into the server with ssh username@ it just works fine. But when I want to do the same using ssh username@servername or username.servername.localdomainname it just does not work.

I read some topics about this and one stated to edit the /etc/resolv.conf file, but in my installation this file has this line as content: DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN. So, I guess I have to change the settings somewhere else.

How do I set up DNS on Ubuntu Server without installing extra software? I want to keep setup as pure as possible. If I look into the /etc/resolv.conf there are two lines, one is like this: search router.localdomainname and one like this nameserver I read that for the DNS to function, it has to look at What to do to change these settings?

DNS works, for example my router's address can be typed into the address bar of my browser and it functions. Also the server name is present in the static ip table of the router.

So, how does one setup DNS right in a local network on Ubuntu server 16.04?

edit: I have opened the network-manager file, found in /etc/dnsmasq.d/. There is a line of text inside it about network-manager. network-manager is an unknown command (I guess it is a GUI program?) But Ubuntu Server does not have a GUI.

edit2: I have tried this: dnslookup router.localdomain from my server and from my workstation (Ubuntu 16.04 with Unity). the server has router IP as DNS server and the workstation uses the router's DNS name is found by both systems. But when I try to lookup my server's name both systems do not find it.

Thanks for reading my question.


  • The resolvconf settings on your server aren't going to affect how clients resolve its name (they are for outgoing lookup); if you don't want to set up an actual DNS server for your local domain you could use avahi/bonjour/mDNS (not sure if that's installed by default in the server installation) to enable addressing in the form servername.local, or use local ssh_config files on the client(s) to map the servername to its IP. Sep 18, 2016 at 13:13

1 Answer 1


Well, I will answer my own question again since I found an easy way to solve my DNS problem. Installing an DNS server looks too complicated for me and a little overkill for a LAN with only 8 systems. The easy way is to edit the hosts file /etc/hosts. Change dir to /etc. first I copied the file with sudo cp hosts hosts.bak. Then (I like nano) sudo nano hosts. And then just add lines just below the localhost line:

  • systemname1
  • systemname2

Save the file and that is it. No need to reload or restart something. This I did on all my systems, and I set and configured static DHCP in my router to keep same IP address to same system.

Hope this helps someone.

  • I have now a new setup with a different router (OpenWRT) and the router seems to handle the DNS issue a lot better than my old router. No need for editing the hosts file on every machine.
    – Marcellus
    Jul 10, 2018 at 11:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.