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?
Asked
Active
Viewed 97 times
1 Answers
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
nslookupand/orhostresolution. Any particular reason you would need DNS resolution to work on your host for your host? – Zina Aug 08 '16 at 17:31