/etc/hosts not being used when DNS is down

We have experienced problems lately with AIX seemingly choosing at random
whether to use the entries in /etc/hosts at all, and if it does, whether
to assign them any kind of priority over DNS. DNS server went down due to
router failure and even though I have fallback entries in /etc/hosts, the
servers stopped communicating by name. No loss of network, as I could
still ping and ssh with IP address, but not by short name or even FQDN.

I removed the nameserver entries from /etc/resolv.conf and then it
immediately started reading the entries in the hosts file, but I wouldn't
think I'd need to.

Isn't the /etc/hosts file typically the first place to look? Is this
something I can set somewhere?

You need to make sure you have a file called netsvc.conf in your /etc directory.
In it you need to put this line:

hosts=local,bind

That is what tells your machine to use the local hosts file first and DNS second.

Then you put into your local hosts file the ips and names of machines that your machine needs to
always know about.

>
> We have experienced problems lately with AIX seemingly choosing at random
> whether to use the entries in /etc/hosts at all, and if it does, whether
> to assign them any kind of priority over DNS. DNS server went down due to
> router failure and even though I have fallback entries in /etc/hosts, the
> servers stopped communicating by name. No loss of network, as I could
> still ping and ssh with IP address, but not by short name or even FQDN.
>
> I removed the nameserver entries from /etc/resolv.conf and then it
> immediately started reading the entries in the hosts file, but I wouldn't
> think I'd need to.
>
> Isn't the /etc/hosts file typically the first place to look? Is this
> something I can set somewhere?
>
> TIA
> John
>
>
>
>
>
>

Hi,
The netsvc.conf tells the server were to look first for the IP look up. If the DNS server is down and you have entries in the host file as well there can be a delay. If the server is trying to communicate with the DNS server it can a few minutes for it to timeout.

Wrong. You want the machine to ALWAYS refrence it's /etc/hosts BEFORE dns. If you don't, then you
have problems when DNS decides not to work.

DNS should never be used in place of the /etc/hosts file for machines to which connectivity is
critical.

Additionaly, you NEVER put alias' into the /etc/hosts file unless you want the machine that hosts
file is on to find those machines by that name.

netsvc.conf must begin with hosts=local,

after that you can put bind,nis or whatever other resolution scheme you want.

not putting hosts=local first breaks your network, causes problems and is a sign of someone that
doesn't know much about how networking should be set up.

> If the netsvc.conf file is set for local,bind the /etc/hosts file is
> referenced before servers in /etc/resolv.conf are tried so that is not
> correct.
>
> The resolution should have been immediate if the entry was in the
> /etc/hosts.
>
> Also, there is no need to refresh inetd after making changes to
> /etc/netsvc.conf. The resolver libraries run on every new connection...
>
> What is the exact entry in /etc/netsvc.conf ? There should be no spaces...
>
> Lamar
>

What do you mean wrong ? I understand what you are saying; but how is
what I said wrong ?

Not sure what you are commenting on with my post below it...

You are correct, you only need critical servers in your /etc/hosts and
should use both the FQDN and short names.

Your comment about not putting hosts=local... is not correct. Also,
this has nothing to do with networking; this is about resolvers and host
name resolution. It will not "break your network" and has little to do
with the actual network stack; but it might make applications that use
reverse lookups run a little slower.

It might have been a timing out issue? There is quite a process AIX uses
to time out with nameservers before using local if local is not listed
first. It can take quite a while to actually time out.....

> > If the netsvc.conf file is set for local,bind the /etc/hosts file is
> > referenced before servers in /etc/resolv.conf are tried so that is
> not
> > correct.
> >
> > The resolution should have been immediate if the entry was in the
> > /etc/hosts.
> >

You are wrong. The netsvc.conf file must be hosts=local,bind so that the local machine reads its
/etc/hosts file BEFORE trying DNS, not after. I am not flaming you either. You are wrong.

If you put bind before local and DNS is not available, then your machine will not even try to read
the local hosts file before timing out on the dns search. That is a very bad thing for the network
admin to insist on doing. If that's how you have your system set up, and you insist on doing so,
believing that you are correct, fine. Do what you like. Expect problems.

Okay, I meant that the hosts line ( hosts= ) when I typed that
information... You are correct what I type was not exactly correct; but
I thought the hosts= was inferred by the previous post.

If you read the rest of the message I agreed with you. Sorry, you are
skipping parts. BUT, the management of 100s of host files is idiotic at
best. I have a stable DNS server running ( on AIX and my team manages )
and have almost never had any issues with it. In fact, I use it for my
DR. I wrote a script to flip the slave to a master and reference all
production servers via CNAME references to their production peers.
Sorry if your environment is not so stable or planned; but the point is
that it will NOT cause a network outage. Only applications using or
requiring reverse resolution will experience slow downs if your DNS is
not available. Thus, why I said a small managable /etc/hosts on a
server is not bad. You seemed to have missed that discussion...

Also, reread your message and mine, we said the same thing... I just
did not precede my answer with the hosts=; but I did say if the
netsvc.conf is set to local,bind that /etc/hosts is referenced before
DNS.

I don't think it is fine. You should have hosts=local,bind in
/etc/netsvc.conf and include your critical servers in /etc/hosts.
Otherwise you are at the mercy of DNS and lost in the woods when it goes
down.

I noticed this comment in my netsvc.conf file on a 5.3 system I've been setting up:

# Any host setting defined in /etc/netsvc.conf file will override the default host order
# and the host setting given in the /etc/irs.conf file.
# The environment variable NSORDER overrides the host settings in the /etc/netsvc.conf file,
# which in turn overrides the host settings in the /etc/irs.conf file.

So you might have NSORDER set somewhere. I noted that my netsvc.conf file is all comments and I don't have a irs.conf file, so I checked my NSORDER - and found it empty too.

I do have a hosts file for critical things, but I didn't realize that it wouldn't be used if DNS went down.

Thanks folks, one more little thing worked out before I put this particular machine into production!