Author Topic: DNS cache - dnsmasq  (Read 4175 times)

Offline janasx1

  • Full Member
  • ***
  • Posts: 147
DNS cache - dnsmasq
« on: February 03, 2011, 06:50:09 PM »
I setup dns caching using dnsmasq.
dnsmasq is a non-persistent DNS cache.

1. Install dnsmasq from synaptic package manager
2. set following parameters in /etc/dnsmasq.conf
resolv-file=/etc/resolv.dnsmasq.conf
listen-address=127.0.0.1
3. create file /etc/resolv.dnsmasq.conf with following lines. (feel free to use your ISP's dns here. I am using openDNS)
nameserver 208.67.222.222
nameserver 208.67.220.220
4. restart dnsmasq
/etc/init.d/dnsmasq restart
5. add 127.0.0.1 as the first dns in your network config.

To clear the cache, restart dnsmasq (#4 above)

To test config, execute below command twice and the time taken for the second request should be much less.
dig www.pclinuxos.com
HP Pavilion notebook DV6400, AMD Turion TL-64, 2GB RAM, broadcom BCM4312, nvidia Geforce Go 6150

Offline muungwana

  • Hero Member
  • *****
  • Posts: 6237
Re: DNS cache - dnsmasq
« Reply #1 on: February 03, 2011, 07:41:47 PM »

5. add 127.0.0.1 as the first dns in your network config.


above line need to be expanded and explained.
.. 3 things are certain in life : death, taxes and software bloat ..
.. tell me something i don't know, something i can use as i struggle to reason with the world around me ..

Offline janasx1

  • Full Member
  • ***
  • Posts: 147
Re: DNS cache - dnsmasq
« Reply #2 on: February 05, 2011, 11:00:24 PM »
Sure.
Here are the steps for #5.

1. open PCLinuxOS Control Center
2. click on network & internet
3. click on network center
4. click on wired/wireless depending on the way you connect
5. If wireless, select the ssid you are connected to
6. click on configure
7. un-check "get DNS servers from dhcp"
8. type in 127.0.0.1 in dns server 1 field.
9. click ok and then quit
HP Pavilion notebook DV6400, AMD Turion TL-64, 2GB RAM, broadcom BCM4312, nvidia Geforce Go 6150

Offline janasx1

  • Full Member
  • ***
  • Posts: 147
Re: DNS cache - dnsmasq
« Reply #3 on: February 06, 2011, 12:06:12 PM »
Here is the explanation.

All the dns requests will be routed to 127.0.0.1 which is dnsmasq. dnsmasq will try to lookup first in the cache and if the cache does not have it, it will look up against opendns servers and puts it in the cache. subsequent requests to dnsmasq will come from the local cache.
HP Pavilion notebook DV6400, AMD Turion TL-64, 2GB RAM, broadcom BCM4312, nvidia Geforce Go 6150

Offline sling-shot

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1730
  • Satyameva Jayate | Truth Alone Triumphs.
Re: DNS cache - dnsmasq
« Reply #4 on: July 04, 2011, 10:20:11 PM »
Request one more clarification:

What is the validity of the cache? Will it be stored on a reboot or cleared? Or will it only be cleared manually?

I shutdown my desktop everyday.

-SS.
Packaging well will cure headaches of many :) But learning to package will cause headaches in many :(

AMD AthlonX2 3600+/ASUS M2NPV-VM/ATi HD4670/Onboard sound/3.5GB DDR2-533 RAM/SEAGATE 160+320GB HDD/DELL S2240L FullHD/Creative SBS370 2.1/PCLinuxOS2013/KDE4
Samsung NP305U1-A06IN | Nokia E6

Offline janasx1

  • Full Member
  • ***
  • Posts: 147
Re: DNS cache - dnsmasq
« Reply #5 on: July 11, 2011, 04:30:50 PM »
I believe its in memory and will get cleared on reboot.
HP Pavilion notebook DV6400, AMD Turion TL-64, 2GB RAM, broadcom BCM4312, nvidia Geforce Go 6150

Offline AndrzejL

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 12797
  • RLU #490933
    • Wordpress On The Wardrobe...
Re: DNS cache - dnsmasq
« Reply #6 on: December 09, 2011, 01:02:21 PM »
As a warning I might add that if You use Internet Connection Sharing and You use Bind - do not use dnsmasq - I tried and it removes bind during installation.

Regards.

Andy

Offline janasx1

  • Full Member
  • ***
  • Posts: 147
Re: DNS cache - dnsmasq
« Reply #7 on: December 09, 2011, 09:19:13 PM »
Hi Andy,
I have another more recent post in tips and tricks about using bind for dns caching.
Thanks
HP Pavilion notebook DV6400, AMD Turion TL-64, 2GB RAM, broadcom BCM4312, nvidia Geforce Go 6150

Offline YouCanToo

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 5331
  • Location: Lebanon, OR., USA
    • Spreading the word.......
Re: DNS cache - dnsmasq
« Reply #8 on: December 09, 2011, 09:31:58 PM »
I setup dns caching using dnsmasq.
dnsmasq is a non-persistent DNS cache.

1. Install dnsmasq from synaptic package manager
2. set following parameters in /etc/dnsmasq.conf
resolv-file=/etc/resolv.dnsmasq.conf
listen-address=127.0.0.1
3. create file /etc/resolv.dnsmasq.conf with following lines. (feel free to use your ISP's dns here. I am using openDNS)
nameserver 208.67.222.222
nameserver 208.67.220.220
4. restart dnsmasq
/etc/init.d/dnsmasq restart
5. add 127.0.0.1 as the first dns in your network config.

To clear the cache, restart dnsmasq (#4 above)

To test config, execute below command twice and the time taken for the second request should be much less.
dig www.pclinuxos.com



How about doing a small write up about this in the howto section of the pclinuxoshelp knowledge base? (http://pclinuxoshelp.com)




Be sure to visit the NEW Knowledge Base


Linux is user-friendly- it's just picky who its friends are!

Offline AndrzejL

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 12797
  • RLU #490933
    • Wordpress On The Wardrobe...
Re: DNS cache - dnsmasq
« Reply #9 on: December 10, 2011, 02:05:02 PM »
Hi Andy,
I have another more recent post in tips and tricks about using bind for dns caching.
Thanks

I cannot find it. Plus I am not saying that Your way is bad with dnsmasq all I am saying - if You use bind - don't use dnsmasq ;).

Andy

Offline AndrzejL

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 12797
  • RLU #490933
    • Wordpress On The Wardrobe...
Re: DNS cache - dnsmasq
« Reply #10 on: December 10, 2011, 02:32:40 PM »
Ah nevermind. I have found it :). It was in the wrong section - not in Tips and Tricks but in Networking.

Here is the link to the bind HOWTO. http://www.pclinuxos.com/forum/index.php/topic,99575.0.html

Will check it out.

Offline janasx1

  • Full Member
  • ***
  • Posts: 147
Re: DNS cache - dnsmasq
« Reply #11 on: December 13, 2011, 05:51:20 PM »
I would love to add this to the knowledge base.
How do I register to login?
Thanks
HP Pavilion notebook DV6400, AMD Turion TL-64, 2GB RAM, broadcom BCM4312, nvidia Geforce Go 6150

Offline YouCanToo

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 5331
  • Location: Lebanon, OR., USA
    • Spreading the word.......
Re: DNS cache - dnsmasq
« Reply #12 on: December 13, 2011, 06:10:42 PM »
I would love to add this to the knowledge base.
How do I register to login?
Thanks

Send me a PM with your username, real name and a working email address. I will setup your account and an email will be sent with a temp password to use, Once you log into the knowledge base you can change your password to what ever you want it to be. Make sure to tell me it is for the knowledge base

YouCanToo




Be sure to visit the NEW Knowledge Base


Linux is user-friendly- it's just picky who its friends are!

Offline janasx1

  • Full Member
  • ***
  • Posts: 147
Re: DNS cache - dnsmasq
« Reply #13 on: December 15, 2011, 09:24:23 PM »
Thanks YouCanToo.
I now have login to the knowledge base.
I am having trouble adding a page to HOWTO category. If I edit it adds to the category page itself.
Thanks
HP Pavilion notebook DV6400, AMD Turion TL-64, 2GB RAM, broadcom BCM4312, nvidia Geforce Go 6150

Offline YouCanToo

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 5331
  • Location: Lebanon, OR., USA
    • Spreading the word.......
Re: DNS cache - dnsmasq
« Reply #14 on: December 15, 2011, 10:22:08 PM »
Thanks YouCanToo.
I now have login to the knowledge base.
I am having trouble adding a page to HOWTO category. If I edit it adds to the category page itself.
Thanks

Log in and goto the HowTo page on the left side in the search box type in the name that you want to name your page and click search.

Example: I typed in "My new page and pressed search. This is the results.

Search results

    Content pages
    Multimedia
    Help and Project pages
    Everything
    Advanced

    Showing below 1 result starting with #1.

Create the page "My new page" on this wiki!

    Live CD faq
    === My CD is in my drive, but when I turn my computer on, nothing different happens === === Why does my computer freeze when trying to boot the live CD? ===
    8 KB (1,470 words) - 22:17, 24 June 2011


Now I clicked on My new page that is in red. The results are this will become your new page (file)  You can than click on "edit" at the top to add your information to the page. You can only edit a page when you are logged into the system.

 MAKE SURE that you add the following to the very bottom of your page on a line by itself

[[Category:HowTo]]

When you are finished with your page make sure that you save it.  Now your new page will automatically be added to the HowTo section in alphabetical order according to the first word of the page name.

In my example the listing would be listed under the letter M since my page name was "My new page"


If you have questions please ask. If you can't figure it out let me know the name you want and I will add it and than you can edit the file as needed.

« Last Edit: December 15, 2011, 10:24:53 PM by YouCanToo »




Be sure to visit the NEW Knowledge Base


Linux is user-friendly- it's just picky who its friends are!