Don’t even start with me about how telnet is horrid. Out side of my control but I recently had issues trying to enable telnet on a server. Typically its pretty straightforward.

  1. yum install telnet-server
  2. chkconfig telnet on
  3. chkconfig xinetd on
  4. service xinetd start

Unfortunately for me this was not working. Every time I tried to telnet to the host after enabling it I would get an error message.

telnet host
Trying 203.0.113.10...
Connected to host (203.0.113.10).
Escape character is '^]'.
getaddrinfo: localhost Name or service not known
Connection closed by foreign host.

I tried everything I could think of, selinux disabled, ensure localhost in /etc/hosts, connect to ip instead of hostname. Nothing was working. All of my searching was just turning up the obligatory “Don’t use telnet, use ssh”.

While that is generally good advice, in the event you are restricted to using telnet it’s not very helpful. Obviously is something related to name resolution. From both sides the fqdn was resolvable. Then it dawned on me. This environment also has the standard of not using the fqdn as the hostname as set in /etc/sysconfig/network. I had not ensured that the shorthand hostname was resolvable. I resolved the error by adding the hostname in /etc/hosts, but adding a default search domain in /etc/resolv.conf would work just as well.

This leads me back to the error message. Really it had nothing to do with “localhost” or “127.0.0.1”. Had it said “host” Name or service not known I would have chased down the issue much sooner.

My ServerFault plea for help