Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

RHEL name resolution

Posted on 2011-09-19
22
Medium Priority
?
440 Views
Last Modified: 2012-05-12
Hi,

How do I force a RHEL server to always use the local host file before attempting to send the request to a DNS server ?

Thanks
0
Comment
Question by:Elemental12
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 6
  • 4
  • +1
22 Comments
 
LVL 21

Expert Comment

by:Papertrip
ID: 36561826
Should be that way by default, but if not then change the 'hosts' line in /etc/nsswitch.conf

hosts:    files dns
0
 

Author Comment

by:Elemental12
ID: 36561933
yup, checked that already, and the file shows:

hosts:      files dns

but for some reason, when I do an nslookup, even if I know the name is wrong, it checks the DNS servers.  For one particular host name, I need it to check the local hosts file, as I do not want it to exist on my DNS servers.
0
 
LVL 71

Expert Comment

by:Chris Dent
ID: 36561988
NsLookup is a debugging tool, it doesn't use the client resolver (whether that's RHEL or any other OS), it queries DNS directly and only.

If you want to test the client, use Ping, or telnet, or something else that relies on the computer to do name resolution.

Chris
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 21

Expert Comment

by:Papertrip
ID: 36562011
nslookup doesn't honor the hosts file, use ping or telnet to test instead.
0
 
LVL 17

Expert Comment

by:James H
ID: 36562055
Do you have Bind installed??
this would work to help resolve names locally.

http://www.experts-exchange.com/Networking/Linux_Networking/Q_26812340.html?sfQueryTermInfo=1+10+30+kennyhenao
0
 

Author Comment

by:Elemental12
ID: 36562397
ahhh, thank you all for telling me that.  How do I go about testing reverse name lookup via an application ?  pinging by IP, just pings by IP, does not give me the host name.
0
 

Author Comment

by:Elemental12
ID: 36562538
I found ping -a for windows ... just looking for the RHEL equivalent
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36562592
Are you asking just how to do a reverse DNS lookup in Linux?

dig -x ip.address
host ip.address
nslookup ip.address

Open in new window

0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36562603
dig is part of the bind-utils package, so you probably don't have it installed by default, but I recommend it above the other 2 options when possible.
0
 

Author Comment

by:Elemental12
ID: 36562657
well, I need a way to do a reverse dns lookup to prove that this server is using the host file first, and DNS second.  I need to use something that honors the host file, as stated above.  Nslookup does not look at the host file as stated above.  I need to prove that this server is using the host file first, and the DNS server second.  How can I prove this ?  I have a fake dns record in my local host file, but when I try to nslookup that fake DNS record, it tries to go to the DNS server to resolve it.  I don't want that.
0
 
LVL 21

Assisted Solution

by:Papertrip
Papertrip earned 1000 total points
ID: 36563028
Is there a specific reason you need to fake the IP as well as the hostname?  I think some of the confusion on this thread from the experts side is that we don't know exactly why you are trying to do this.

All you can "prove" with any of this testing is whether a certain application (ping, nslookup, host) honors /etc/hosts.  Proving that everything on the server is using it, that would be a pain and probably not worth the time.

If you need to fake both forward and reverse lookups to make sure that every single query for a specific hostname/ip gets the fake results, no matter what sends the query, then you need to setup a DNS server with fake zones for any host/ip you want to modify.

0
 

Author Comment

by:Elemental12
ID: 36563063
Yes, I am adding a host to the local host file because I do not want to create an entire dns server or zone for just one host.

yes, all I want to prove is that if I put in an IP address in my local hosts file, any name resolution will respect what is in the host file first, and DNS second.  So for example if my host file has

172.16.1.1      fake1.domain.com

but DNS server has 172.16.1.1 as real1.domain.com, when the server goes to 172.16.1.1, I want it to believe the name that belongs to that IP is fake1.domain.com
0
 
LVL 71

Expert Comment

by:Chris Dent
ID: 36563124
Both forward and reverse (should) load into the client cache from hosts by default, you might try enabling debugging with nscd (perhaps). Not a Unix / Linux expert so I don't have a reasonable suggestion beyond that.

Chris
0
 

Author Comment

by:Elemental12
ID: 36563202
I was thinking of restarting nscd, which would clear cache, but higherups were not happy with that idea.
0
 
LVL 17

Expert Comment

by:James H
ID: 36563206
Linux doesn't work that way with DNS.
You can't use HOST file for name resolution.
You will have to setup DNS for what you are asking for.
0
 

Author Comment

by:Elemental12
ID: 36567505
Linux does not use host files ?
0
 
LVL 17

Expert Comment

by:James H
ID: 36567583
Yes, Linux does use host files but for what you are trying to do it will not work.
You cannot "trick" the OS into resolving a local name with a HOST entry.
You will need to setup DNS for this purpose.
0
 
LVL 71

Expert Comment

by:Chris Dent
ID: 36567645
Um, why not?

It's a name, it doesn't need a Hosts file entry and a DNS entry, it's not a trick, it's a legitimate name resolution technique.

Chris
0
 

Author Comment

by:Elemental12
ID: 36575262
Yes, the word "trick" is a bad word I am using ...

I have been able, in Windows anyway, to put in different names for the same IP and when that server does to any of those different names, the requests are set to the same IP.
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36575312
You can't prove that everything on the system that needs DNS resolution is going to honor the hosts file.  The way to do this is by serving up the fake zone file, but even then you may have an app using a built-in resolver that you can't control.

Making fake entries in /etc/hosts is generally used only temporarily and for testing/troubleshooting purposes.  Anything more than that should be done through DNS.
0
 
LVL 71

Accepted Solution

by:
Chris Dent earned 1000 total points
ID: 36575654
I still think it's situational, and hosts is an entirely legitimate mechanism (for far more than testing). But it's very true to say (as Papertrip has) that if an application has it's own resolver, and that's what you're trying to tweak, no amount of messing with hosts will help.

Chris
0
 

Author Closing Comment

by:Elemental12
ID: 36814801
We found out it was a coding issue after all that was deciding the host name to IP, regardless of what I did in the host file.  I decided to split the points equally though due to the effort from both of you, and the accuracy of your answers.  Thank you very much.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There have been a lot of times when we have seen the need to enter a large number of DNS entries in a forward lookup zone. The standard procedure would be to launch the DNS Manager console, create the Zone and start adding new hosts using the New…
Configuring network clients can be a chore, especially if there are a large number of them or a lot of itinerant users.  DHCP dynamically manages this process, much to the relief of users and administrators alike!
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

664 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question