LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 04-28-2013, 01:15 AM   #1
keirvt
Member
 
Registered: Sep 2006
Location: Sydney Australia
Distribution: fedora/Ubuntu
Posts: 156

Rep: Reputation: 18
/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
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
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: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
...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: 156

Original Poster
Rep: Reputation: 18
/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: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
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



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

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

All times are GMT -5. The time now is 12:20 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