LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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 04-28-2013, 01:15 AM   #1
keirvt
Member
 
Registered: Sep 2006
Location: Sydney Australia
Distribution: fedora/Ubuntu
Posts: 80

Rep: Reputation: 15
/etc/hosts file not working


I can get mys hosts file entries to resolve and changes to the hosts file don't show up on nslookup. I'm running Ubuntu
Some search engine blogs are saying that the hosts file isn't checked by DNS lookups but that is exactly what I want it for.

So my nsswitch.conf.conf is
Code:
passwd:         compat
group:          compat
shadow:         compat

#hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4
hosts:          files dns
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files
If I insert an entry into /etc/hosts; say
Code:
123.456.654.321 KVT
(in this instance the IP is non existant
Code:
nslookup kvt
Server:		203.2.75.132
Address:	203.2.75.132#53

** server can't find kvt: NXDOMAIN
I can ping the host entry kvt but nslookup or dig fails
to find it. This is extremely useful for local addresses but I am suspecting that Ubuntu and others have discontinued this. I really don't want to install my own DNS server.
 
Old 04-28-2013, 03:34 AM   #2
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,938

Rep: Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341
Quote:
Some search engine blogs are saying that the hosts file isn't checked by DNS lookups but that is exactly what I want it for.
This is true.
The dns tools (dig, nslookup, host) are using exclusively the dns server(s) in /etc/resolv.conf in order to resolve hostnames.
Ping like other programs that run over the network (like your browser for example) are using the entries in /etc/nsswitch.conf to find the order for a hostname resolution. (in your case 1st /etc/hosts and then a dns server)
 
Old 04-28-2013, 05:48 AM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,492
Blog Entries: 54

Rep: Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910
...additionally, unless you have constraints you haven't talked about:
Quote:
Originally Posted by keirvt View Post
I really don't want to install my own DNS server.
it isn't very difficult if you use Dnsmasq or Pdnsd instead of ISC BINDs caching-nameserver. Pdnsd reads /etc/hosts by default IIRC, creates the appropriate DNS entries for them and you can modify any record on the fly.
 
Old 04-28-2013, 05:06 PM   #4
keirvt
Member
 
Registered: Sep 2006
Location: Sydney Australia
Distribution: fedora/Ubuntu
Posts: 80

Original Poster
Rep: Reputation: 15
/etc/hosts yes you are correct

I still think the /etc/hosts file should be consulted by the DNS and I have only found this from Networkmanager on Ubuntu. I'm sure there are others.

dnsmasq is a solution and its very easy to implement so thank you for the suggestion. I actually started to install a DNS server when I saw the posts!

I notice there are many other people encountering this very annoying enhancement to the OS.

Thanks for your help.
 
Old 04-28-2013, 07:40 PM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,492
Blog Entries: 54

Rep: Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910
Quote:
Originally Posted by keirvt View Post
I still think the /etc/hosts file should be consulted by the DNS (..) I notice there are many other people encountering this very annoying enhancement to the OS.
GNU/Linux is Open Source and Free For All. You're welcome to submit your patches to the Glibc developers.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
my hosts.allow hosts.deny not working twlilinux Linux - Newbie 7 06-19-2008 07:20 AM
can't restrict sshd access through hosts.allow and hosts.deny but was working earlier farhan Linux - Security 4 04-18-2008 07:41 AM
windows hosts file, not working anymore with squid :( spatieman Linux - Software 4 02-16-2005 03:39 PM
does the /etc/hosts file work same as the M$ hosts file? Lleb_KCir Linux - Software 6 04-03-2004 04:33 PM
hosts file not working Tekime Linux - Networking 4 04-09-2002 08:06 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration