After reading tutorials on the internet, I don't succeded to set a domain name to an IP adress in debian. here is my /etc/resolv.conf:

domain localdomain
search localdomain

domain utopia.net
search utopia.net

but it doesn't works when for example I try : ssh root@utopia.net but ssh root@ works so, why ? I want that the utopia.net server works and point to the IP...

  • Arre and name servers? Did you create a DNS zone? or you meant to use /etc/hosts file? – Nicola Sarobba Feb 11 '16 at 15:11
  • don't post screenshots when plain text will do. an image is useless and can be unreadable on high-resolution screens. text is both readable and editable and google-able. – cas Feb 21 '16 at 3:14

/etc/resolv.conf does not set mappings between names and IP addresses. It only tells your computer what servers to ask for the conversion (DNS servers, aka nameservers).

You have two options:

  • the "static option" (which does not actually use DNS) is to add your entry to /etc/hosts: add a line such as: utopia.net

    and you should be all set. This will override the actual IP of utopia.net, but will only be valid on the computer where you added this informations to /etc/hosts

  • the actual DNS option: you need to have a domain name registered, and within the "zone" for that domain name, declare the mapping to an IP address. This would work on any computer using DNS, but requires you to "buy" (lease, really) a domain name and properly configure it

There also an alternative which is to have your own "local" domain name, configure it on your own name server, and configure computers to use that name server for resolution. This would allow you to have the mapping available on several computers, while still have to change the mapping from name to IP in a single place. But that's probably beyond the scope of your current capabilities.

  • Yes, but Debian is installed on a virtual machine and I would like that utopia.net ( works outside my virtual machine, but into my computer, for example to use wih ssh – John Mary Feb 11 '16 at 15:22
  • You can edit /etc/hosts on every machine you want to use that name on (including Mac OS X, which is really a Unix variant, and Windows, though the location on Windows is a bit more fun IIRC). You actually don't need to configure it on the target machine, only on those where you want to use it. The alternative is to use an actual domain name, either a "real" one valid on any computer that uses DNS, or a local one, which will be valid only on computers using the nameserver(s) where you have added that mapping. – jcaron Feb 11 '16 at 15:30

It's not /etc/resolv.conf that you must modify. That file is used to specify the DNS servers that the local machine will use for name resolution.

What you want to do is to map an IP address to a fully qualified hostname, for use by your local machine only. The local mappings between IP addresses and FQDNs are in /etc/hosts, and that's the file you must edit according to the following format (example taken from the hosts manpage):

   # The following lines are desirable for IPv4 capable hosts       localhost

   # is often used for the FQDN of the machine       thishost.mydomain.org  thishost    foo.mydomain.org       foo    bar.mydomain.org       bar    master.debian.org      master  www.opensource.org

Forget setting up DNS records -- that's not what you want to do.

  • Ok I edited my /etc/hosts file and inside there is debian.utopia.net debian. And when I try from my Macintosh (host) to do ssh@debian.utopia.net, it doesn't work. It is not normal because ssh@ works – John Mary Feb 11 '16 at 15:17
  • Do a service networking restart and then retry. – dr01 Feb 11 '16 at 15:23
  • ssh: Could not resolve hostname debian.utopia.net: nodename nor servname provided, or not known – John Mary Feb 11 '16 at 15:29
  • Edit /etc/hosts on your Mac, not on the target server. You'll need to sudo. – jcaron Feb 11 '16 at 15:31
  • Please do a grep hosts: /etc/nsswitch.conf. It should normally show host: files (...). – dr01 Feb 11 '16 at 15:32

Is the domain utopia.net registered to you (extremely unlikely because according to whois it has been continuously registered since 1995)?

If not, then don't use it.

The DNS would completely break if everyone who liked the sound of a domain just decided to use it in their internal networks without regard to the fact that the domain belongs to someone else. "Oh, I really like google.com, that's a pretty name - I'll just use that for my private LAN. Too bad none of my users can get to that obscure search engine thingy".

If you don't want to register (i.e. buy/lease) a domain and install and configure a name-server then just install a zeroconf server like avahi and then you'll be able to ssh hostname.local.

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.