Operating System - HP-UX
1824936 Members
3892 Online
109678 Solutions
New Discussion юеВ

Error in hostname resolution

 
Manish_33
Advisor

Error in hostname resolution

Hi Friends,

I have an application which takes a hostname as a parameter. My problem is that it is able to resolve hostnames, ip addresses but not "localhost". What I could guess from the output of tusc is that it is trying to resolve hostname from dns while it should have tried /etc/hosts first. My nsswitch.conf has entries like
passwd: files
group: files
hosts: files dns
services: files
networks: files
protocols: files
rpc: files
publickey: files
netgroup: files
automount: files
aliases: files


Therefore I expect it to open /usr/lib/libnss_files.1 first instead of libnss_dns.1.


Below is a snapshot of tusc trace. Any suggestions. ???

open("/etc/nsswitch.conf", O_RDONLY, 0666) ............................................................ = 5
ioctl(5, TCGETA, 0x7a0030a8) .......................................................................... ERR#25 ENOTTY
read(5, "# \n# / e t c / n s s w i t c ".., 8192) ................................................... = 401
read(5, 0x40011020, 8192) ............................................................................. = 0
close(5) .............................................................................................. = 0
open("/usr/lib/libnss_dns.1", O_RDONLY, 0) ............................................................ = 5
fstat(5, 0x7a003018) .................................................................................. = 0
read(5, "0210010e0512@ \0\0\0\0\0\0\0\0\0".., 128) .................................................... = 128
lseek(5, 128, SEEK_SET) ............................................................................... = 128
read(5, "10\0\004\0\0\0( \0\0S ec\0\010\0".., 48) ..................................................... = 48
read(5, "80\0\0\v\0\0\004\0\0\0\0", 12) ............................................................... = 12
6 REPLIES 6
Jaime Bolanos Rojas.
Honored Contributor

Re: Error in hostname resolution

Manish,

Please run an nslookup ipaddress-server
You should see that the resolution was made by the /etc/hosts file.

If this is the case, then the problem must be with the application.

Regards,

Jaime.
Work hard when the need comes out.
Manish_33
Advisor

Re: Error in hostname resolution

Hi,

Yes nslookup resolves it correctly and that too using files. When I give "localhos" instead of localhost my application tries dns first and then after few steps tries files which I assume is because it was unable to resolve from dns.

Shouldn't that happen for localhost too. Somehow it is also trying to open /etc/environment file. I am not sure why is that ?????.....
Jaime Bolanos Rojas.
Honored Contributor

Re: Error in hostname resolution

Manish,

Make sure that you have this line in your /etc/hosts file:

127.0.0.1 localhost loopback

Regards,

Jaime.
Work hard when the need comes out.
A. Clay Stephenson
Acclaimed Contributor

Re: Error in hostname resolution

/etc/environment is not a standard file so I suspect it was created for/by your application. You may be able to edit it to change your application's behavior.

As a workaround, you should be able to create a DNS localhost entry although that more or less defeats the purpose because localhost should be able to be resolved whether or not a viable network is available.
If it ain't broke, I can fix that.
HGN
Honored Contributor

Re: Error in hostname resolution

Hi

If you think this issues is resolved you can close this thread and also provide points to the people who have helped.
You have only given points to 1 out of 33 responses, hpe you understand that people spend their valuable time helping and to by assigning point it shows gratitude for their help even a 1 point is better than not assigning

Rgds

HGN
Manish_33
Advisor

Re: Error in hostname resolution

Hi,

Sorry HGN. I admit my mistake. Thanks everyone for answering. but yet the issue is not resolved :-( that is why i am not closing the thread.