LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-21-2012, 07:08 AM   #1
jstuardo
LQ Newbie
 
Registered: Dec 2011
Posts: 7

Rep: Reputation: Disabled
host command does not use hosts file


Hello...

I have RHEL 5 with a hosts file listing this entry:

192.168.1.8 OFICINA-XX

When I run: "ping OFICINA-XX", the name is correctly resolved.

But when I run: "host OFICINA-XX" this error occurs:

Host OFICINA-XX not found: 3(NXDOMAIN)

How can I make host command to recognize the name?

Thanks a lot in advance
Jaime
 
Old 02-21-2012, 07:12 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
It doesn't, it is for DNS lookups only. This is completely by design.
 
Old 02-21-2012, 07:17 AM   #3
david1941
Member
 
Registered: May 2005
Location: St. Louis, MO
Distribution: CentOS7
Posts: 267

Rep: Reputation: 58
The host command uses the /etc/resolv.conf file to know who to ask and not your hosts file, while other commands usually will use the hosts file.
 
Old 02-25-2012, 02:52 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Look at the "getent" command. getent hosts <hostname>
This will use /etc/hosts or dns if /etc/resolv.conf and /etc/nsswitch.conf are configured properly.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
if I edit the /etc/hosts file how to detect the new host without restarting the pc RMLinux Linux - Newbie 3 02-18-2009 06:27 PM
/etc/hosts My unqualified host name? DMeerholz Linux - Networking 1 02-01-2008 02:54 AM
need a command line utility that will upload a file to a host Leb_CRX Linux - General 4 10-01-2007 12:35 PM
Possible to have a dynamic host entry in hosts file? bbarron Linux - Networking 3 06-28-2006 07:01 PM
HOST name in HOSTS file (127.0.0.1) fipeso Linux - Networking 1 05-05-2005 06:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 10:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration