HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Force nslookup use hosts file not the DNS
Operating System - Linux
        1839859
        Members
    
    
        2657
        Online
    
    
        110156
        Solutions
    
Forums
        Categories
Company
Local Language
                
                  
                  back
                
        
                
        
                
        
                
        
        
        
                
        
                
        
        
        
                
        
              
              Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
                
                  
                  back
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
            
                
            
                
            
                
            
                
            
            
                
            
                
            
            
                
            
                
              
            Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
        Information
        Community
Resources
Community Language
        Language
        Forums
Blogs
	
		
			
            
                
            Go to solution
        
            
		
		
			
            	
	
		
        
		
	
	
		Topic Options
			
				
					
	
			
		
	- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2011 06:44 AM
02-22-2011 06:44 AM
			
				
					
					
						Hello smarts,
I am trying to force to use hosts file rather than DNS(resolv.conf), on RHEL 5.4. But doesn't work.
The order in /etc/host.conf has the following:
order hosts,bind
And the /etc/nsswitch.conf has the following:
[root]# grep hosts /etc/nsswitch.conf
#hosts: db files nisplus nis dns
#hosts: files dns
hosts: files
[root]#
[root]# nslookup
Server:
Address:
** server can't find: NXDOMAIN
[root]
Any ideas gurus? 
		
		
	
	
	
I am trying to force to use hosts file rather than DNS(resolv.conf), on RHEL 5.4. But doesn't work.
The order in /etc/host.conf has the following:
order hosts,bind
And the /etc/nsswitch.conf has the following:
[root]# grep hosts /etc/nsswitch.conf
#hosts: db files nisplus nis dns
#hosts: files dns
hosts: files
[root]#
[root]# nslookup
Server:
Address:
** server can't find
[root]
Any ideas gurus?
Solved! Go to Solution.
		3 REPLIES 3
	
	            
            
		
		
			
            
                - Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2011 08:05 AM
02-22-2011 08:05 AM
Solution
			
				
					
					
						The nslookup command is originally a DNS server testing tool. The RHEL default version of nslookup will always try to contact a DNS server, because that's what it's programmed to do.
If you want to test the name resolver libraries (which use whatever is configured to /etc/nsswitch.conf), you'll need to use another tool: the "getent" command.
In your case, the command syntax is "getent hosts"
Note: the "hosts" in the getent command line does not refer to /etc/hosts directly, but to the "hosts:" line in /etc/nsswitch.conf.
The getent command can be used to test other lookup mechanisms specified in /etc/nsswitch.conf too: for example, if you're setting up LDAP and need to verify that usernames are being looked up from your chosen source, you might run a command like "getent passwd".
MK  
					
				
			
			
				
		
		
	
	
	
If you want to test the name resolver libraries (which use whatever is configured to /etc/nsswitch.conf), you'll need to use another tool: the "getent" command.
In your case, the command syntax is "getent hosts
Note: the "hosts" in the getent command line does not refer to /etc/hosts directly, but to the "hosts:" line in /etc/nsswitch.conf.
The getent command can be used to test other lookup mechanisms specified in /etc/nsswitch.conf too: for example, if you're setting up LDAP and need to verify that usernames are being looked up from your chosen source, you might run a command like "getent passwd
MK
	MK
			
			
				
			
			
			
			
			
			
		- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2011 08:40 AM
02-22-2011 08:40 AM
			
				
					
						
							Re: Force nslookup use hosts file not the DNS
						
					
					
				
			
		
	
			
	
	
	
	
	
			
				
					
					
						Mk, Thank you for the response. But getent doesn't work in my situation as one of the application is looking for the ip address which s specified in hosts file, as the DNS server has the new IP, which we haven't changed yet due to the downtime issue. Of course eventually we will change and I know it works then. Meanwhile, I thought nslookup might work looking at the hosts file rather than the resolv.conf file. But looks like not.
Thank you for the information, really very helpful.
		
		
	
	
	
Thank you for the information, really very helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2011 06:25 AM
02-25-2011 06:25 AM
			
				
					
						
							Re: Force nslookup use hosts file not the DNS
						
					
					
				
			
		
	
			
	
	
	
	
	
			
				
					
					
						how about a simple ping ?
as Matti mentioned, use a different tool.
					
				
			
			
				
			
			
				
			
			
			
			
			
			
		
		
		
	
	
	
as Matti mentioned, use a different tool.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
		
	
	
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP
