Author Topic: HOWTO: DNS caching  (Read 1528 times)

Offline janasx1

  • Full Member
  • ***
  • Posts: 147
HOWTO: DNS caching
« on: November 15, 2011, 09:56:32 PM »
Hi,
This posting is to let others know how I configured DNS caching and improved browsing performance.

1. installed package bind-utils for dig/nslookup
2. installed package bind
3. In PCLinuxOS Control Center > System > "Manage system services..."
4. clicked Start button for named service
5. changed network config to use 127.0.0.1 as the first DNS server and the second DNS to one of the openDNS. I do have both openDNS servers (208.67.222.222 208.67.220.220) configured in my wireless router.

tried "dig www.google.com" twice and can see significant difference in the time to resolve to ip.

I think when a dns request is sent, named tries to get from its cache and if not found, it tries with the dns from the default gateway (router in my case) and then caches it for subsequent requests.

Hope this helps.
Thanks
HP Pavilion notebook DV6400, AMD Turion TL-64, 2GB RAM, broadcom BCM4312, nvidia Geforce Go 6150

Offline gseaman

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 3791
Re: HOWTO: DNS caching
« Reply #1 on: November 15, 2011, 10:35:52 PM »
In PCC, bind does not like localhost as the domain. It says that you need a FQDN, fully qualified domain name. When I change the hostname it still says that localhost is not a FDQN. Any tips on this part?

Galen

Offline janasx1

  • Full Member
  • ***
  • Posts: 147
Re: HOWTO: DNS caching
« Reply #2 on: November 20, 2011, 06:14:50 PM »
Hi Galen,
In my hosts file, I have 2 entries for 127.0.0.1

127.0.0.1  compname.somedomain
127.0.0.1 localhost

In /etc/sysconfig/network, I set the HOSTNAME=compname.somedomain

Please try and let me know if it works.
Thanks
HP Pavilion notebook DV6400, AMD Turion TL-64, 2GB RAM, broadcom BCM4312, nvidia Geforce Go 6150

Offline AndrzejL

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 12795
  • RLU #490933
    • Wordpress On The Wardrobe...
Re: HOWTO: DNS caching
« Reply #3 on: December 10, 2011, 02:55:08 PM »
Hi :).

This stuff is good!

I am using named as a part of my Internet Connection Sharing - it's my DNS server so I already have all the tools needed. What I did was:

Edited this file:

Code: [Select]
/etc/resolvconf/resolv.conf.d/base
so it looks like this:

Quote
[root@icsserver andrzejl]# cat /etc/resolvconf/resolv.conf.d/base
nameserver 127.0.0.1

No empty lines at the end.

and then I have edited this file:

Code: [Select]
/etc/resolvconf/resolv.conf.d/tail
so it looks like this:

Quote
[root@icsserver andrzejl]# cat /etc/resolvconf/resolv.conf.d/tail
nameserver 208.67.222.222
nameserver 208.67.220.220

Again - no empty lines at the end.

So now when I ran:

Quote
service network restart

and my connection got re-established:

Quote
[root@icsserver andrzejl]# service network restart
Shutting down interface eth1:                                              [  OK  ]
Shutting down interface ppp0:                                              [  OK  ]
Shutting down loopback interface:                                          [  OK  ]
Disabling IPv4 packet forwarding:                                          [  OK  ]
Bringing up loopback interface:                                            [  OK  ]
Enabling IPv4 packet forwarding                                            [  OK  ]
Configuring wireless regulatory domain                                     [  OK  ]
Bringing up interface eth1:                                                [  OK  ]
Bringing up interface ppp0:                                                [  OK  ]
[root@icsserver andrzejl]#

I am getting this in my:

Code: [Select]
/etc/resolv.conf
Quote
[root@icsserver andrzejl]# cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.0.1
nameserver 208.67.222.222
nameserver 208.67.220.220

Why this way? Because I am using 3G USB Dongle from three.ie and I don't get to setup my own DNS while connecting. The only way to setup my own DNS for 3G network is to override it with the resolvconf daemon :).

BUT that's not the point ;)!

This is the point :).

First shot:

Quote
[andrzejl@icsserver ~]$ dig pclinuxos.com

; <<>> DiG 9.8.1-P1 <<>> pclinuxos.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 10203
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 0

...

;; Query time: 265 msec

...

;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Sat Dec 10 21:41:28 2011
;; MSG SIZE  rcvd: 131

Quote
[andrzejl@icsserver ~]$ dig pclinuxos.com

; <<>> DiG 9.8.1-P1 <<>> pclinuxos.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8272
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 2

...

;; Query time: 1 msec

...

;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Sat Dec 10 21:41:29 2011
;; MSG SIZE  rcvd: 163

Nice difference and the sites are loading slightly faster! ;).

Thanks Janasx1!

Offline janasx1

  • Full Member
  • ***
  • Posts: 147
Re: HOWTO: DNS caching
« Reply #4 on: December 13, 2011, 05:18:04 PM »
Thanks AndrzejL.
I didnt know about the base and tail file.
HP Pavilion notebook DV6400, AMD Turion TL-64, 2GB RAM, broadcom BCM4312, nvidia Geforce Go 6150

Offline AndrzejL

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 12795
  • RLU #490933
    • Wordpress On The Wardrobe...
Re: HOWTO: DNS caching
« Reply #5 on: December 13, 2011, 08:48:32 PM »
Thanks AndrzejL.
I didnt know about the base and tail file.


Cool :) there is also a head file :)