LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-22-2009, 07:17 PM   #1
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,052

Rep: Reputation: 70
Can I use my /etc/hosts file as a person DNS server?


I only normally visit around 10 sites tops when surfing the net. Can I just include all the entries in the /etc/hosts file? So in theory, if I did this, and I only visited those 10 sites for the rest of my life, my computer would never access my ISP's name servers to resolve one of the domain names that I have listed in my /etc/hosts file? Also, if I connected wirelessly to my router, would there be any need for

echo "nameserver 192.168.1.1" > /etc/resolv.conf

?

Also, if the /etc/hosts file does do what I'm thinking it does, is there a file equivalent to the hosts file but on windows xp?

Last edited by trist007; 03-22-2009 at 07:20 PM.
 
Old 03-22-2009, 07:19 PM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,627

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
why not just use " OpenDNS " http://www.opendns.com/
 
Old 03-22-2009, 08:18 PM   #3
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,052

Original Poster
Rep: Reputation: 70
If I just use those 10 sites, then wouldn't I get better performance on resolving?
 
Old 03-22-2009, 08:33 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by trist007 View Post
I only normally visit around 10 sites tops when surfing the net. Can I just include all the entries in the /etc/hosts file? So in theory, if I did this, and I only visited those 10 sites for the rest of my life, my computer would never access my ISP's name servers to resolve one of the domain names that I have listed in my /etc/hosts file?
Unless their IP addresses change or they get taken down
that should work just fine.

Quote:
Originally Posted by trist007 View Post
Also, if I connected wirelessly to my router, would there be any need for

echo "nameserver 192.168.1.1" > /etc/resolv.conf

?
If you're not using DNS at all you wouldn't need your
router to be a server... how come you have to echo this,
though? Is it not handing out a new resolv.conf as part
of dhcp? Is it overwriting it with non-sensical data?

Quote:
Originally Posted by trist007 View Post
Also, if the /etc/hosts file does do what I'm thinking it does, is there a file equivalent to the hosts file but on windows xp?
There should be a file lmhosts under the windows directory
somewhere, but I'm not a windows guy ...
 
Old 03-22-2009, 08:36 PM   #5
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
I think the windows version is is just hosts as well. Just search for it, since it's location seems to vary
 
Old 03-22-2009, 09:58 PM   #6
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,052

Original Poster
Rep: Reputation: 70
If I'm using dns and I have all the domain entries in /etc/hosts for that computer, then there's no need to use my router for dns right?

Yea the echo thing is just a habit, hehe.

Also, let's say the above is true, can I setup all my other computers in my network to use ip address of this computer with /etc/hosts file for dns? I would just make sure port 53 is open on the computer with the /etc/hosts file.

Last edited by trist007; 03-22-2009 at 10:57 PM.
 
Old 03-23-2009, 12:18 AM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Also, let's say the above is true, can I setup all my other computers in my network to use ip address of this computer with /etc/hosts file for dns? I would just make sure port 53 is open on the computer with the /etc/hosts file.
Nope, that ain't gonna fly ... it's just a file, meant for local
lookups. If you want the machine to serve IPs to other boxes on
the local network you'll need some sort of DNS server process.


Quote:
If I'm using dns and I have all the domain entries in /etc/hosts for that computer, then there's no need to use my router for dns right?
Correct (as long as there's no changes of DNS for the machines you're
trying to connect to using the info in your hosts file).


Cheers,
Tink
 
Old 03-23-2009, 03:55 AM   #8
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,070

Rep: Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897
Quote:
Originally Posted by Tinkster View Post
Nope, that ain't gonna fly ... it's just a file, meant for local
lookups. If you want the machine to serve IPs to other boxes on
the local network you'll need some sort of DNS server process.
I think that you could sort-of make it work (not quite sure why you would want to....you sound like a candidate for pdns, dnsmasq, maradns, djbdns.. all of which will avoid the problem of ip addresses changing and give you, in general, reasonably quick look-up times).

If you run squid on the 'server' as a proxy, dns look up occurs local to squid rather than local to your browser and if squid is running on the machine with the doctored hosts file, that should give you what you seem to want. Plus caching, of course, which may not be a big win, but it is probably a small win all on its own.

Note that this would only work with things like the browser that use squid's proxying capabilities; this doesn't include things like command line utilities (ping, etc) and might not include some utilities that have similar ca[pabilities to ping or even some browser-like things that can't be set up to use the proxy (rss viewers?).
 
Old 03-23-2009, 04:58 PM   #9
JaksoDebr
Member
 
Registered: Mar 2009
Distribution: Fedora, Slackware
Posts: 104

Rep: Reputation: 21
You can use /etc/hosts for a lot more sites then 10. With web browsers doing their caching anyway, you could use even hundred entries in /etc/hosts, and still not notice a difference. It is more likely to wait for the remote server to respond, then to wait for your local PC to look-up domains/IPs from /etc/hosts.

I use /etc/hosts entries for local testing of websites, that I'm working on. It's an easy way to switch between the remote server and the local development version, without messing up anything on the production. Having 20-30 such entries hasn't caused problems.

Linux Archive

Last edited by JaksoDebr; 04-02-2009 at 04:55 AM.
 
  


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
DNS doesn't resolv hosts that are on internal DNS Tux-Slack Linux - Networking 8 06-03-2008 06:42 AM
Moving a Fedora 7 Web Server that uses plesk and hosts DNS oldcarguy85 Linux - Server 1 04-20-2008 07:56 AM
i want make DNS server on fedora 8 opreting system plz tell me what is file use DNS nitin gupta Linux - Newbie 2 02-20-2008 05:01 PM
File server, print server inaccessible when change to new DNS tanveer Linux - Server 0 07-31-2007 03:21 AM
Cache DNS server and zone file DanielTan Linux - Networking 7 09-26-2005 11:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:30 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
Open Source Consulting | Domain Registration