LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-08-2009, 06:07 PM   #1
targettl
Member
 
Registered: Sep 2009
Location: Launceston
Distribution: Kubuntu
Posts: 84

Rep: Reputation: 16
hosts file not being read


I want to use /etc/hosts to save lookup times as they have been slow recently. But it appears that my system isn't reading this file.
nslookup localhost will return 127.0.0.1 but everything else fails.

I put a pretend address in /etc/hosts
99.99.99.99 dkjfkdjfkdjfdkkd.com dkjfkdjfkdjfdkkd

nsswitch.conf may be relevent
passwd: compat
group: compat
shadow: compat

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

protocols: db files
services: db files
ethers: db files
rpc: db files

netgroup: nis

As you can see files is first for hosts:
nslookup dkjfkdjfkdjfdkkd.com
host not found
 
Old 12-08-2009, 06:38 PM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650
nslookup will query name servers, just try to ping it

eg.
Code:
cat << EOF >> /etc/hosts
10.0.0.1	testbox.mydomain.local testbox
EOF

# ping testbox
PING testbox.mydomain.local (10.0.0.1) 56(84) bytes of data.
...
cheers
 
Old 12-08-2009, 07:02 PM   #3
targettl
Member
 
Registered: Sep 2009
Location: Launceston
Distribution: Kubuntu
Posts: 84

Original Poster
Rep: Reputation: 16
Okay thanks. Basically nslookup will only look at dns servers and not the hosts file. But ping will read the hosts file first.
ping kdjfdijdmnf33jdefkmdfj9ejf39kdm.com
PING kdjfdijdmnf33jdefkmdfj9ejf39kdm.com (99.99.99.99) 56(84) bytes of data.

I guess some programs have been made not to read the hosts file. I know postfix does not read the hosts file as i was having trouble once because there were no local dns servers available.
 
Old 12-08-2009, 07:12 PM   #4
targettl
Member
 
Registered: Sep 2009
Location: Launceston
Distribution: Kubuntu
Posts: 84

Original Poster
Rep: Reputation: 16
What would be a good way to measure the time it takes to resolve the name.
 
Old 12-08-2009, 07:14 PM   #5
targettl
Member
 
Registered: Sep 2009
Location: Launceston
Distribution: Kubuntu
Posts: 84

Original Poster
Rep: Reputation: 16
My answer "dig site.com"
 
Old 12-08-2009, 07:23 PM   #6
targettl
Member
 
Registered: Sep 2009
Location: Launceston
Distribution: Kubuntu
Posts: 84

Original Poster
Rep: Reputation: 16
Actually no that isn't good as it doesn't read the hosts file either.
 
Old 12-10-2009, 03:25 AM   #7
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650
I think the time taken to check the hosts file would be fairly minimal, and the time taken to resolve a name via your ISP's name servers would vary according to load and bandwidth usage. If you took enough samples over a long period the data may be vaguely relevant:

In one terminal:
Code:
tcpdump -n -i eth0 port 80
In a second terminal:
Code:
wget www.google.com
The output from tcpdump will have timestamps giving you an estimate of the time taken for a dns query/response pair of packets, but as I said, the data is not very relevant unless you collected enough samples


cheers
 
Old 12-10-2009, 03:57 AM   #8
targettl
Member
 
Registered: Sep 2009
Location: Launceston
Distribution: Kubuntu
Posts: 84

Original Poster
Rep: Reputation: 16
20:55:35.889833 IP 192.168.34.70.39196 > 66.235.120.101.80: Flags [.], ack 4381, win 229, length 0
20:55:35.899599 IP 66.235.120.101.80 > 192.168.34.70.39196: Flags [P.], seq 4381:5841, ack 375, win 54, length 1460

This was taken during a lookup of ask.com. However this doesn't really mean much to me.
 
  


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
How to tell what process last wrote to a file? - hosts file being updated by unk kcoriginal Linux - General 1 12-28-2008 11:53 PM
Read Only File System? Can't read superblock! haughjd Linux - Software 4 01-15-2008 08:27 AM
cupsd does not read hosts.allow/deny properly jarome Linux - Software 2 01-03-2007 02:50 PM
does the /etc/hosts file work same as the M$ hosts file? Lleb_KCir Linux - Software 6 04-03-2004 04:33 PM
Change from Read only to Read Write File System? justiceisblind Linux - Newbie 3 03-03-2002 07:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:07 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration