My Solaris System lookup DNS first instead of files

Dear all,
   I'm facing a strange problem : my solaris server use DNS to resolve a host first before using files.
   I check the nsswitch.conf and see that the setting is correct :

hosts :    files     dns
ipnodes:   files   dns

  My hosts file : /etc/hosts
 192.168.1.1        abcserver

  But when I ping :   ping -s  abcserver
                  64 bytes replied from abcserver.com.vn  (72.xxx.xxx.xxx)
                  64 bytes replied from abcserver.com.vn  (72.xxx.xxx.xxx)
     With  72.xxx.xxx.xxx is an internet IP
 
  When I use command : getent hosts abcserver
     The result is OK :   abcserver   192.168.1.1

  So, I don't know what the problem was ? Please help me to fix It.
  Best regards.

 
sacombank-sbsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AmolCommented:
clear your hosts cache and then try,

nscd –i hosts
0
Brian UtterbackPrinciple Software EngineerCommented:
Is it possible that you are not using the bundled system ping program? Try running
"which ping".

0
Joseph GanSystem AdminCommented:
First of all checking /etc/hosts should be linked to /etc/inet/hosts with the same contain.
Secondly which version of Solaris it is.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Joseph GanSystem AdminCommented:
Also verify the local host by

# ping -s localhosts

and check the /etc/hosts file should have this entry:

127.0.0.1       localhost loghost loopback
0
Joseph GanSystem AdminCommented:
The reason asking version of Solaris was as follow:

"hosts:" in /etc/nsswitch.conf  is used only if the /etc/netconfig file has a "-" for nametoaddr_libs of "inet" transports in early version of Solaris.
0
sacombank-sbsAuthor Commented:
I fixed the problem by :
cat /etc/hosts >> /etc/inet/ipnodes

I wonder why my system just check ipnodes file  instead of hosts file.
0
Brian UtterbackPrinciple Software EngineerCommented:
You never said what version of Solaris you are using, but if it is a newer version of Solaris 10 or Open Solaris, then there is supposed to only be one file, /etc/inet/hosts. The other two files (/etc/inet/ipnodes, /etc/hosts) are both supposed to be
symbolic links to the /etc/inet/hosts file.
0
Joseph GanSystem AdminCommented:
cat /etc/hosts >> /etc/inet/ipnodes

You shoudln't do that. Instead put this entry "127.0.0.1       localhost loghost loopback" in the hosts file.

The entries of /etc/inet/ipnodes file only contains few information than the hosts file, samething like:

#
# Internet host table
#
::1             localhost
127.0.0.1       localhost

One of them is the localhost entry!
0
sacombank-sbsAuthor Commented:
We are using Solaris 10 . Actually, I was faced with this issue with Solaris 8    3 years ago.
As Ganios said that the ipnodes files should contain few information that the hosts file, I don't think make a symbolic link to hosts file is a good idea (It's not default for Solaris, is it ?)
But I still don't know why my Solaris system use ipnodes instead of hosts ? May be some cases this issue happens ?
0
Joseph GanSystem AdminCommented:
Check if both files are hard linked ?
0
Joseph GanSystem AdminCommented:
Also have tried put localhost in /etc/hosts file?
0
sacombank-sbsAuthor Commented:
No hard link, they are separated files . All settings are correct (localhosts, ip, ..)
0
Joseph GanSystem AdminCommented:
Can you tried this in /etc/nsswitch.conf file

hosts :    files     dns
ipnodes:   files

Without dns in the end at ipnodes?
0
Joseph GanSystem AdminCommented:
According to the notes in /etc/nsswitch.conf:

"Note that IPv4 addresses are searched in all of the ipnodes databases before
searching the hosts databases."

Because in your /etc/nsswitch.conf have the following:

hosts :    files     dns
ipnodes:   files   dns

If it couldn't find it in ipnodes file, will go to dns. If you take out dns, it then will go to hosts file.

Hope this is the answer.
0
Brian UtterbackPrinciple Software EngineerCommented:
You can fix it like this:

Make sure that /etc/inet/hosts if a real file and not a link, and it has all the entries you need.
Then run these two commands as root:

echo /etc/inet/ipnodes | pkgchk -i - -f
echo /etc/hosts | pkgchk -i - -f

Don't forget the dash after the -i.
0
neteducationCommented:
Original Solaris Setting are:

Before Solaris 8: There was only /etc/inet/hosts. /etc/hosts was a hard link to /etc/inet/hosts
Solaris 8 & 9: There was independant /etc/inet/hosts (for IPv4) and /etc/inet/ipnodes (for IPv6). If a name needed to be resolved, hosts was taken before inodes. /etc/hosts was a link to /etc/inet/hosts (hardlink though, so was not recognized by many people that it actually was a link)
Solaris 10 first few verserion: there was independant /etc/inet/hosts  (for IPv4) and /etc/inet/ipnodes (for IPv6). If a name needed to be resolved, ipnodes was taken before hosts (!!!). /etc/hosts was a link to /etc/inet/hosts
More or less current Solaris 10 Versions:
There is only one File: /etc/inet/hosts. /etc/inet/ipnodes and /etc/hosts are symbolic links to /etc/inet/hosts

So if you have them in a different way let me suggest to change back to the default. That will give you the least problems.
0
sacombank-sbsAuthor Commented:
but why although I have a host in /etc/hosts file, It still use DNS first ? If as you say, It takes ipnodes before hosts , It must see my hosts in hosts file instead of using DNS

When I set in my nsswitch.conf :
  hosts :   files  
  ipnodes : files dns

It could detect the host in my /etc/hosts file
But when I set in my nsswitch.conf :
  hosts : files   dns
  ipnodes : files dns

It took dns first and didn't detect host in my hosts file.
I must add host into  ipnodes file to work arround.
That's the problem which I don't know why.


0
Brian UtterbackPrinciple Software EngineerCommented:
When you had the host in the host file but not the ipnodes file, then the search order becomes:

ipnodes file, DNS, hosts file, DNS.

So, it looks in the ipnodes file, doesn't find the host, then checks DNS. The DNS naming service has it's own search rules, so it actually looks for several different hostnames depending on the contents of  your /etc/resolv.conf file. So, DNS finds an answer, although it is not theone you expected. Once it gets an answer, the search is stopped and the DNS answer is returned to the program. So the hosts
file is never consulted. With the getent command, it is starting with the hosts file, so it gets what you expected.

Is it clear now?
0
neteducationCommented:
Ok, I need to be more precise:

If your /etc/hosts (which normally is a link to /etc/inet/hosts) and your /etc/inet/ipnodes (which in newer versions of solaris 10 a link to /etc/inet/hosts, but used to be just a simple independent file) are two different files (that is not one is a link to the other, or both to a thrid file), then this is what happens:

If your nsswitch.conf looks like this:
hosts :   files  
ipnodes : files dns

Then it goes tries to do it in the following order:
ipnodes/files ipnodes/dns hosts/files

In the first two it only searches for IPv6, therefore does not find it -> entry in hosts/files is taken.


If your nsswitch.conf looks like this:
  hosts : files   dns
  ipnodes : files dns

it trys to optimizpe, not querying the DNS-Server twice and therefore it tries like this:
ipnodes/files dns(both V6 and V4) hosts/files

In your situation this makes it a bit confusing , but name services lookup is something where you can spend a lot of time, slowing down applications, that's why sun has on the one hand the nscd (name service cache daemon) and on the other hand optimizations like this.
0
sacombank-sbsAuthor Commented:
The explanation of neteducation seems be right . Is It true as the way Solaris 10 work ?
0
neteducationCommented:
I'm not completly sure if the first view version of Solaris 10 have already done like this, but at least since Solaris 10 U5 (aka Solaris 10 5/08) it has been like this.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sacombank-sbsAuthor Commented:
Closed , 250 points.
0
Joseph GanSystem AdminCommented:
I have already provided the right answer on 31/03, but did not get any credit !!!
0
sacombank-sbsAuthor Commented:
I'm sorry because your answer wasn't right with my issue because you said that "if it couldn't find it in ipnodes file, will go to dns. If you take out dns, it then will go to hosts file." . But actually , It can use hosts file first (instead of use dns of ipnodes) if I use:
hosts:  files
ipnodes:  files dns

This question is closed here.
Thank you for your all support
0
Joseph GanSystem AdminCommented:
Thats because you copied hosts file over to ipnodes

I fixed the problem by :
cat /etc/hosts >> /etc/inet/ipnodes
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.