4

We have a server on the company network named serverA, and if I type ssh serverA, it will connect my PC to this server, even though there is no entry for this server in my /etc/hosts, but I used to have another PC where I do have to set this up manually in /etc/hosts. So, how does ssh discover hostnames on the network, and how can I make sure it works? (Both these machines I mentioned are running Kubuntu Linux, the older one runs 12.10, the newer one runs 13.04.)

I have the following content in /etc/resolv.conf:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.1.1
search mycompany.com

Processes listening on port 53:

sudo ss -ulnp | grep 53
#UNCONN     0      0                         *:5353                     *:*      users:(("avahi-daemon",937,12))
#UNCONN     0      0                 127.0.1.1:53                       *:*      users:(("dnsmasq",1781,4))
#UNCONN     0      0                        :::5353                    :::*      users:(("avahi-daemon",937,13))
6
  • 2
    Does you network have a DNS server? Does it have an entry for serverA ?
    – Hennes
    Jul 22, 2013 at 12:40
  • @Hennes I don't really know, but I have posted the resolve.conf above, could you have a look? Thanks.
    – qed
    Jul 22, 2013 at 13:01
  • You have this line nameserver 127.0.1.1 which tells the resolver to try to translate hostnames to IP addresses. The IP of the nameserver starts with 127, and 127/8 points back to your own host. So you probably are running a nameserver on your own computer.
    – Hennes
    Jul 22, 2013 at 13:04
  • 1
    What process is listening locally on your box on port 53? sudo ss -ulnp | grep 53
    – Matt
    Jul 22, 2013 at 13:15
  • @mindthemonkey Please see the edited post.
    – qed
    Jul 22, 2013 at 15:38

2 Answers 2

3

The OpenSSH client uses the standard DNS resolver provided by your operating system to resolve host names to an IP address.

The hosts config in /etc/nsswitch.conf configures what should be looked at to resolve hosts and and in what order.

Normally most lookups will be completed by the dns resolver which is configured in /etc/resolv.conf. You probably need to contact the person who administers the nameserver noted in /etc/resolv.conf and ask them to configure the hostname/IP for you, which in your case of 127.0.1.1 appears to be yourself. If you have a dynamic DHCP IP address this might not be possible depending on your setup.

If mdns or Multicast DNS is what enables your working host, your new host might be on a different subnet or not broadcasting it's name.

2

This happens when the server is within the DNS search domain you have configured.

For example, my current search domain is example.com:

$ grep ^search /etc/resolv.conf
search example.com

I can now do the following transparently:

$ ping foo.example.com
PING foo.example.com (127.0.0.1) 56(84) bytes of data.
^C
$ ping foo
PING foo.example.com (127.0.0.1) 56(84) bytes of data.
^C

Search domains allow automatic translation between the machine's name and the fully qualified domain name (FQDN).

2
  • My resolve.conf has a line search example.com, so what's the difference between search and domain?
    – qed
    Jul 22, 2013 at 13:07
  • Just a note, domain example.com configures the local domain which the search domain defaults to. The search domain can additionally be configured with search example.com someextradomain.com
    – Matt
    Jul 22, 2013 at 13:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .