LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 01-02-2013, 04:55 PM   #1
LeoPap
Member
 
Registered: Jan 2013
Distribution: Centos
Posts: 93

Rep: Reputation: 4
[SOLVED] How to create a caching dns server in centos


Hello all,
I would like to setup a caching dns server on my existing Linux server, ( Centos 6.3) in order to increase the speed of browsing websites for the rest of the network.

Can please someone help me with that? Where should I start?

Thank you in advance!

Cheers,
Leo

Last edited by LeoPap; 01-08-2013 at 02:22 AM.
 
Old 01-02-2013, 04:59 PM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,592
Blog Entries: 2

Rep: Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045
I use dnsmasq for that purpose, here is a tutorial for CentOS: http://www.g-loaded.eu/2010/09/18/ca...using-dnsmasq/
 
Old 01-02-2013, 05:09 PM   #3
LeoPap
Member
 
Registered: Jan 2013
Distribution: Centos
Posts: 93

Original Poster
Rep: Reputation: 4
Post

Quote:
Originally Posted by TobiSGD View Post
I use dnsmasq for that purpose, here is a tutorial for CentOS: http://www.g-loaded.eu/2010/09/18/ca...using-dnsmasq/
Thank you very much for your reply mate.
Did you see better results in your web browsing experience?

Also on my windows system I have some local websites saved on /etc/hosts. ( also I should say that I am using a windows server with IIS for hosting my websites)
Will this bother me towards the installation?

Note: I am talking about the host file on a windows pc. Not a Linux.
 
Old 01-02-2013, 05:12 PM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,592
Blog Entries: 2

Rep: Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045
I use it together with Polipo (caching proxy server) to get better load times. I share a connection with rather low bandwidth with a bunch of other people and I can see significantly better load times, especially when the connection is under heavy load.

Regarding the Windows machine: I don't know.
 
Old 01-03-2013, 03:27 AM   #5
LeoPap
Member
 
Registered: Jan 2013
Distribution: Centos
Posts: 93

Original Poster
Rep: Reputation: 4
Quote:
Originally Posted by TobiSGD View Post
I use it together with Polipo (caching proxy server) to get better load times. I share a connection with rather low bandwidth with a bunch of other people and I can see significantly better load times, especially when the connection is under heavy load.

Regarding the Windows machine: I don't know.

Hello mate,
I install the cache server and it seems to work fine! Thank you very much!!

I have 2 questions although:

1) I set the cache-size=1000 (as the tutorial suggest), can you please explain me how exactly this works?
I mean this is for 1000 websites, or for 1000 times i visit random webisites? Will i have to change this number in the future?

2)How can i be 100% sure that dns caching actually works? The tutorial doesn't say anything about changing something in clients pc. My topology right now is: Router --> Firewall --> Switch. On the switch it is connected the linux server ( with dns caching) and three client pc with Windows XP.

Thank again,
Leo

Thanks again!

Last edited by LeoPap; 01-03-2013 at 05:02 AM.
 
Old 01-03-2013, 06:06 AM   #6
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,592
Blog Entries: 2

Rep: Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045
I have set the cache-size to 10000, it is the number of DNS queries that is cached, you can't directly translate that to the number of websites. For example, if a website shows you pictures from different domains you will have multiple DNS queries on that site.

On your client, you have to configure them to use the server as nameserver, easily done with the network configuration dialog on Windows or /etc/resolv.conf on Linux systems.
To test if the caching is actually working you can use the dig command.
 
Old 01-03-2013, 06:13 AM   #7
LeoPap
Member
 
Registered: Jan 2013
Distribution: Centos
Posts: 93

Original Poster
Rep: Reputation: 4
Quote:
Originally Posted by TobiSGD View Post
I have set the cache-size to 10000, it is the number of DNS queries that is cached, you can't directly translate that to the number of websites. For example, if a website shows you pictures from different domains you will have multiple DNS queries on that site.

On your client, you have to configure them to use the server as nameserver, easily done with the network configuration dialog on Windows or /etc/resolv.conf on Linux systems.
To test if the caching is actually working you can use the dig command.
running dig www.bbc.com i get these results.

;;Query time: 0 msec
;; SERVER 127.0.0.1#53 (127.0.0.1)

Also i try ping bbc.com and it is not working..i get a unknown host..
So obviously the dns caching is not working...

Leo

Last edited by LeoPap; 01-03-2013 at 06:20 AM.
 
Old 01-03-2013, 06:18 AM   #8
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,592
Blog Entries: 2

Rep: Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045
It is working correctly.

On Windows, you don't have to change the default gateway, but the DNS server.
 
Old 01-03-2013, 06:32 AM   #9
LeoPap
Member
 
Registered: Jan 2013
Distribution: Centos
Posts: 93

Original Poster
Rep: Reputation: 4
Quote:
Originally Posted by TobiSGD View Post
It is working correctly.

On Windows, you don't have to change the default gateway, but the DNS server.
But how it is working if i can't ping a web address from the server which is installed the caching dns?

Also on the Windows PC i change the dns with the ip of the cached server (192.168.1.200) but i don't have internet connection!

Any ideas please?

i use this script:

#
# Configuration file for dnsmasq acting as a caching nameserver.
#
# Format is one option per line, legal options are the same
# as the long options legal on the command line. See
# "/usr/sbin/dnsmasq --help" or "man 8 dnsmasq" for details.
#
# Updated versions of this configuration file may be available at:
#
# http://www.g-loaded.eu/2010/09/18/ca...using-dnsmasq/
#

#
# Basic server configuration
#

listen-address=127.0.0.1
port=53
bind-interfaces
user=dnsmasq
group=dnsmasq
pid-file=/var/run/dnsmasq.pid

#
# Logging
#

#log-facility=/var/log/dnsmasq.log
#log-queries

#
# Name resolution options
#

domain-needed
bogus-priv
no-hosts
dns-forward-max=150
cache-size=1000
#no-negcache
neg-ttl=3600
resolv-file=/etc/resolv.dnsmasq
no-poll

log-facility=/var/log/dnsmasq.log


Thank you!

Leo

edit: Any help?

Last edited by LeoPap; 01-04-2013 at 07:05 AM.
 
Old 01-04-2013, 07:07 AM   #10
LeoPap
Member
 
Registered: Jan 2013
Distribution: Centos
Posts: 93

Original Poster
Rep: Reputation: 4
Quote:
Originally Posted by TobiSGD View Post
It is working correctly.

On Windows, you don't have to change the default gateway, but the DNS server.

Any help mate? Is my configuration file correct?

Cheers,
Leo
 
Old 01-04-2013, 08:08 AM   #11
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,592
Blog Entries: 2

Rep: Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045
Sorry, I missed your last post.
This is my configuration file:
Code:
interface=br0
listen-address=127.0.0.1
port=53
bind-interfaces
user=dnsmasq
group=dnsmasq
pid-file=/var/run/dnsmasq.pid
domain-needed
bogus-priv
dns-forward-max=150
cache-size=10000
neg-ttl=600
resolv-file=/etc/resolv.dnsmasq
no-poll
This is my resolv.conf and resolv.dnsmasq:
Code:
tobi@server ~ ☺ $ cat /etc/resolv.conf 
nameserver 127.0.0.1
tobi@server ~ ☺ $ cat /etc/resolv.dnsmasq
nameserver 8.8.8.8
nameserver 208.67.222.222
nameserver 192.168.178.1
And here is my dig output:
Code:
dig google.de

; <<>> DiG 9.7.3 <<>> google.de
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 28994
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;google.de.			IN	A

;; ANSWER SECTION:
google.de.		94	IN	A	173.194.44.56
google.de.		94	IN	A	173.194.44.63
google.de.		94	IN	A	173.194.44.55

;; Query time: 51 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Fri Jan  4 15:02:40 2013
;; MSG SIZE  rcvd: 75
I misinterpreted your last dig output, the one I posted is one that is working.
Hope this may be helpful.

Last edited by TobiSGD; 01-04-2013 at 08:25 AM.
 
Old 01-07-2013, 02:39 AM   #12
LeoPap
Member
 
Registered: Jan 2013
Distribution: Centos
Posts: 93

Original Poster
Rep: Reputation: 4
Quote:
Originally Posted by TobiSGD View Post
Sorry, I missed your last post.
This is my configuration file:
Code:
interface=br0
listen-address=127.0.0.1
port=53
bind-interfaces
user=dnsmasq
group=dnsmasq
pid-file=/var/run/dnsmasq.pid
domain-needed
bogus-priv
dns-forward-max=150
cache-size=10000
neg-ttl=600
resolv-file=/etc/resolv.dnsmasq
no-poll
This is my resolv.conf and resolv.dnsmasq:
Code:
tobi@server ~ ☺ $ cat /etc/resolv.conf 
nameserver 127.0.0.1
tobi@server ~ ☺ $ cat /etc/resolv.dnsmasq
nameserver 8.8.8.8
nameserver 208.67.222.222
nameserver 192.168.178.1
And here is my dig output:
Code:
dig google.de

; <<>> DiG 9.7.3 <<>> google.de
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 28994
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;google.de.			IN	A

;; ANSWER SECTION:
google.de.		94	IN	A	173.194.44.56
google.de.		94	IN	A	173.194.44.63
google.de.		94	IN	A	173.194.44.55

;; Query time: 51 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Fri Jan  4 15:02:40 2013
;; MSG SIZE  rcvd: 75
I misinterpreted your last dig output, the one I posted is one that is working.
Hope this may be helpful.
Hello,
I am missing the /etc/resolv.dnsmasq file.
When i run cat /etc/resolv.dnsmasq i got result " No such File or Directory".

I remove and re-install the dnsmasq and still the resolv.dnsmasq is not there. Will i have to create it? I am using your configuration! ( Except the interface=br0 i use interface=etho )

Please help!

Last edited by LeoPap; 01-07-2013 at 02:59 AM.
 
Old 01-07-2013, 06:35 AM   #13
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,592
Blog Entries: 2

Rep: Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045Reputation: 4045
If you use my configuration you have to use the resolv.dnsmasq file, otherwise dnsmasq does not know where to look up the addresses. Just create the file and put the content in. The first address in that file is a public Google server, the second address is an OpenDNS server. You can omit the third address, it is an address local to my network and not reachable from the outside.
 
Old 01-07-2013, 10:27 AM   #14
LeoPap
Member
 
Registered: Jan 2013
Distribution: Centos
Posts: 93

Original Poster
Rep: Reputation: 4
I create the file and everything seems to work fine, but on my windows pc when i change the DNS server at the ip of the caching server ( 192.168.1.200) i don't have internet connection. Can you help me with that?

The caching server has the following configuration:

ip: 192.168.1.200
mask: 255.255.255.0
gateway 192.168.1.1
primary DNS 127.0.0.1
secondary DNS 127.0.0.1

i can ping google.de and here are the results of the dig command:


; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.e16_3.6 <<>> google.de
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47558
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;google.de. IN A

;; ANSWER SECTION:
google.de. 212 IN A 173.194.67.94

;; Query time: 1 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Jan 7 16:25:39 2013
;; MSG SIZE rcvd: 43

Also at the resolv.dnsmasq file i have make this configuration:

nameserver 8.8.8.8
nameserver 208.67.222.222

Last edited by LeoPap; 01-07-2013 at 10:28 AM.
 
Old 01-07-2013, 10:41 AM   #15
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,260
Blog Entries: 54

Rep: Reputation: 2841Reputation: 2841Reputation: 2841Reputation: 2841Reputation: 2841Reputation: 2841Reputation: 2841Reputation: 2841Reputation: 2841Reputation: 2841Reputation: 2841
Sorry for barging in this late in the thread.

Quote:
Originally Posted by TobiSGD View Post
I use dnsmasq for that purpose
I'd like to point out that AFAIK cached information won't survive a restart of Dnsmasq or the machine it runs on. Pdnsd OTOH does have persistent caching.
 
  


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
new samba server create problem centos 5.5 64bits salimshahzad Linux - Newbie 2 02-07-2011 02:45 PM
i have server which has Linux version centos i want to create the image of the server dhirendrs Linux - Newbie 6 07-22-2010 08:20 PM
i have one server which install the Centos OS and i want to create the image dhirendrs Linux - Enterprise 3 07-22-2010 03:11 PM
LXer: Create Your Own Web Server With BIND And Apache On CentOS 5 LXer Syndicated Linux News 0 07-02-2008 03:11 PM


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

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