0

I have set up all the necessary configurations to set up a static host besides localhost (default) on Ubuntu, but I can ping the host I set with the /etc/host file but I cant use nslookup or the host command to resolve it. By the way I have checked resolve.conf files and nsswitch.conf . It says NXdomain. Any advice?

  • This question is off topic for SO. Try asking it on [unix.se] or [ubuntu.se]. – Gerald Schneider Aug 08 '16 at 13:30
  • @GeraldSchneider I agree. Someone who is familiar with Ubuntu can determine the correct answer. If adding/editing the hostname entry in /etc/sysconfig/network works in Ubuntu, this should be a *nix question. If Ubuntu does it differently, then it should go there. – Jeter-work Aug 08 '16 at 15:36
  • @sravnv - as the answers & comments say, you need DNS for nslookup and/or host resolution. Any particular reason you would need DNS resolution to work on your host for your host? – Zina Aug 08 '16 at 17:31

1 Answers1

0

If you want to use nslookup or host command to resolve your hostname, you would need to setup a local dns server because by default Ubuntu wont use the gethost command to resolve the info from host files, therefore external applications that require host name resolve or sockets wont e able to find your static host. Like i said set up a local DNS server, its quite easy and straight forward. Use this Link: https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-ubuntu-14-04 Good luck!

  • Hostname resolution goes 1. cache, 2. hosts file, 3. DNS. Any system call for name resolution goes through these steps. Setting up a DNS server may seem simple and straightforward, but doing so dramatically increases your attack surface, and hardening DNS is not easy. – Jeter-work Aug 08 '16 at 15:36
  • @Xalorous - nslookup asks DNS. So without a valid DNS record there will be no nslookup different from NXDomain. As for the hostname resolution you are right (while it was possible to change the order - see here), but the OP asked why nslookup does not resolve. The same for the host command, it performs a DNS lookup so will NEVER return anything from the hosts file. – Zina Aug 08 '16 at 17:28