0

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
nameserver 172.16.170.2

domain utopia.net
search utopia.net
nameserver 172.16.170.135

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

  • Arre 172.16.170.2 and 172.16.170.135 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
0

/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:

    172.16.170.135 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 (172.16.170.135) 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
0

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
   127.0.0.1       localhost

   # 127.0.1.1 is often used for the FQDN of the machine
   127.0.1.1       thishost.mydomain.org  thishost
   192.168.1.10    foo.mydomain.org       foo
   192.168.1.13    bar.mydomain.org       bar
   146.82.138.7    master.debian.org      master
   209.237.226.90  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 172.16.170.135 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@172.16.170.135 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
-1

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.