Showing results for 
Search instead for 
Did you mean: 

DNS instead of /etc/hosts

Go to solution

DNS instead of /etc/hosts

When I originally set up my box I never bothered configuring any DNS stuff. Since I usually only connect to a few specific machines, I added the hostnames and IPs into my /etc/hosts and I was good to go.

When I do ftp or telnet into a host other than those specified in /etc/hosts, I have to use the IP. This usually involves pinging the address from my PC just to get the IP. Very annoying. Where can I find information on correcting my problem and telling my box to look at some DNS to resolve hostnames. I've read the "named" man page, but I think I'm missing something. How do I tell "named" where to look?

BTW, I'm on HP-UX 11.00.


Re: DNS instead of /etc/hosts

Sorry. I accidentally posted this message to the "Databases" section. I reposted to the Sys Admin section. Please ignore this.
Mike Wilcox
Occasional Visitor

Re: DNS instead of /etc/hosts

There are 2 files in /etc that you will need to modify. /etc/nsswitch.conf and /etc/resolv.conf.

In the /etc/resolv.conf...


In the /etc/nsswitch.conf, change the hosts entry to read...

hosts: files [NOTFOUND=CONTINUE] dns

You should be able to do DNS resolution of host names not in your host file now.

good luck.
Joseph C. Denman
Honored Contributor

Re: DNS instead of /etc/hosts

Hi Blake,

You just need to do a couple of things.

1. Create or modify /etc/resolv.conf to look as follows:
nameserver (primary DNS)
nameserver (secondary DNS)

2. Create or modify /etc/nsswitch.conf to have an entry as follows:
hosts: files [NOTFOUND=continue] dns

That should do it.

If I had only read the instructions first??
Trusted Contributor

Re: DNS instead of /etc/hosts

1. /etc/rc.config.d/namesvrs
set NAMED=1

Client side
2. /etc/resolv.conf
add search list and nameserver entires

3. /etc/nsswitch.conf
hosts: dns files

Re: DNS instead of /etc/hosts

Thanks everybody! That did the trick.