Page 4 of 5 FirstFirst ... 2345 LastLast
Results 31 to 40 of 44

Thread: HOWTO: Persistant DNS Caching with pdnsd.

  1. #31
    Join Date
    Jun 2008
    Beans
    1

    Re: HOWTO: Persistant DNS Caching with pdnsd.

    I think it's working on my hardy using poopypants step. Moreover, how to set it as dns proxy for networked computer?? It should be possible I guess. Thanks.

  2. #32
    Join Date
    Jun 2007
    Location
    In my own little world...
    Beans
    320
    Distro
    Lubuntu

    Re: HOWTO: Persistant DNS Caching with pdnsd.

    I wrote a perl program a while back to analyze the relative speeds of each of the DNS servers detected by dhcpcd (DHCP client daemon) through use of dig (a DNS lookup utility) and display a sorted list of DNS servers from fastest to slowest.

    Here's the perl script and the corresponding output from the command line:

    Code:
    #!/usr/bin/perl 
    
    ######################################################################################
    # scan_dns.pl version 0.7 9/20/07
    # Author: Warren Watts (kingbeetle_66(at)yahoo(dot)com
    
    # This program will analyze the relative speeds of each of the DNS servers
    # detected by dhcpcd (DHCP client daemon) through use of dig (a DNS lookup utility)
    # and display a sorted list of DNS servers from fastest to slowest.
    # This sorted list can then be used to tweak the /etc/resolv.conf file, providing
    # faster DNS lookups while browsing, etc.
     
    # I included three domains for dig to lookup.  They are stored in @domain_list.
    # Feel free to add to the list or change the domain list to any domains you wish.
    # Be aware that the more domains in the list, the longer the scan will take!
    #######################################################################################
    
    use strict;
    
    my (@DNS,$IP,$time,$domain,$dig,%time,$key);
    
    # Read the DNS list from /etc/resolv.conf and store the list in an array
    my $resolv = `cat /etc/resolv.conf`;
    while ($resolv =~ /nameserver (.*)\n/g) {push(@DNS,$1)}
    
    #List the DNS servers listed in /etc.resolv.conf
    print "+----------------------------------------------------------------------+\n";
    print "The following DNS servers are listed in /etc/resolv.conf:\n";
    foreach $IP (@DNS) {print "$IP\t"}
    print "\n";
    
    # Store list of domains to be looked up by dig in an array
    my @domain_list = ('www.yahoo.com' ,'www.fasthit.net' ,'zz.nullwave.ru');
    
    # List the domains to be used by dig during the scan
    print "The following domains will be for this scan:\n";
    foreach $domain (@domain_list) {print "$domain\t"}
    print "\n";
    print "+----------------------------------------------------------------------+\n";
    
    # Count number of domains stored in the array
    my $domain_count = @domain_list; 
    # Go through the list of DNS servers and execute dig for each DNS server and each  
    # domains in the domain list, extract the time taken and average the times together,
    # then store the DNS and averaged time in a hash.
    foreach $IP (@DNS) 
    {
      print "Scanning $IP\n";
      $time = '';
      foreach $domain (@domain_list)
      {
        print "-->  $domain\n";
        $dig = `dig \@$IP $domain`;
        if ($dig =~ /Query time: (.*) msec/) 
        {
          $time = $time + $1;
        }
      }
      $time{$IP} = int(($time / $domain_count) +0.5);
    }
    print "+----------------------------------------------------------------------+\n";
    
    # Display the results sorted by time in ascending order
    foreach my $key (sort hashValueAscendingNum (keys(%time))) 
     {
      print "Average fetch time for $key : $time{$key}\n";
    }
    
    # Subroutine to sort by time rather than by DNS address
    sub hashValueAscendingNum 
    {
       $time{$a} <=> $time{$b}
    }

    Sample output:
    everyone@ubuntu550:~/Desktop$ perl test.pl
    +----------------------------------------------------------------------+
    The following DNS servers are listed in /etc/resolv.conf:
    208.67.222.222 208.67.220.220 192.168.0.1
    The following domains will be for this scan:
    www.yahoo.com www.fasthit.net zz.nullwave.ru
    +----------------------------------------------------------------------+
    Scanning 208.67.222.222
    --> www.yahoo.com
    --> www.fasthit.net
    --> zz.nullwave.ru
    Scanning 208.67.220.220
    --> www.yahoo.com
    --> www.fasthit.net
    --> zz.nullwave.ru
    Scanning 192.168.0.1
    --> www.yahoo.com
    --> www.fasthit.net
    --> zz.nullwave.ru
    +----------------------------------------------------------------------+
    Average fetch time for 208.67.222.222 : 43
    Average fetch time for 208.67.220.220 : 291
    Average fetch time for 192.168.0.1 : 834
    You should be able to use this to test whether your local DNS cache is working, right?

    I also included the script as a handy tarball as well.
    Attached Files Attached Files
    Badges? We ain't got no badges. We don't need no badges. I don't have to show you any stinking badges!
    Adventures In Linux

  3. #33
    Join Date
    May 2006
    Location
    Redmond, WA
    Beans
    57
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: HOWTO: Persistant DNS Caching with pdnsd.

    This is all I did in Jaunty, without any config file editing.

    Quick Summary:

    Code:
    sudo cp /etc/resolv.conf /etc/resolv.conf.bak
    sudo apt-get install resolvconf
    sudo apt-get install pdnsd
    Choose "Use resolvconf". In the next line, replace eth0 with the name of your interface if it's different.

    Code:
    sudo mv /etc/resolv.conf.bak /etc/resolvconf/run/interface/eth0
    sudo resolvconf -u
    Done! If you want step-by-step explanations:

    Longer Steps:

    First, save your current nameserver setup (this is not superfluous paranoia, you're going to need this later):

    Code:
    sudo cp /etc/resolv.conf /etc/resolv.conf.bak
    Next install resolvconf. If we don't install it first, we'll get weird errors from pdnsd because of how resolvconf replaces the /etc/resolv.conf file with a symbolic link:

    Code:
    sudo apt-get install resolvconf
    Next install pdnsd:

    Code:
    sudo apt-get install pdnsd
    Choose "Use resolvconf".

    You'd assume that it would just work, but it doesn't, cause the setup process has lost your original nameserver information.

    So when you try to resolve a name, the system will look to resolvconf, who'll direct the request to pdnsd. Pdns has nothing cached yet, so it asks resolvconf for the next server to check, but resolvconf has no one to ask next.

    So, we tell resolvconf that for that network interface, to use the config we were using before we started any of this. So move the backup file we made where resolvconf can see it. Since this was for my eth0 interface, I used:

    Code:
    sudo mv /etc/resolv.conf.bak /etc/resolvconf/run/interface/eth0
    Finally, update resolvconf with:

    Code:
    sudo resolvconf -u
    Took me a few tries to pare this down, but this works for me, end to end.

    For a wireless config (where you're connecting to different networks), or if you just want to use say, OpenDNS for all of your interfaces all the time, just create a file /etc/resolvconf/run/interface/opendns with the following:
    Code:
    nameserver 208.67.222.222
    nameserver 208.67.220.220
    Then update resolvconf again with:

    Code:
    sudo resolvconf -u
    Hope this helps!
    Hester: 12.04 Desktop x64 | Core i5-2540M @ 2.6 GHz | 16GB DDR3 | 80GB SSD + 256GB SSD
    Cortana: 12.04 Desktop x86 | Atom N270 @ 1.6 GHz | 2GB DDR2 | 32GB SSD
    Horatio: 12.04 Server x64 | Atom N330 @ 1.6 GHz | 1GB DDR2 | 2.5TB

  4. #34
    Join Date
    Jul 2006
    Beans
    18

    Re: HOWTO: Persistant DNS Caching with pdnsd.

    wow it worked from the help of above post real short and simple
    Last edited by noren; October 12th, 2009 at 08:24 PM.

  5. #35
    Join Date
    Jun 2008
    Location
    Malmoe, Sweden
    Beans
    6
    Distro
    Xubuntu 8.04 Hardy Heron

    Re: HOWTO: Persistant DNS Caching with pdnsd.

    Quote Originally Posted by aladinonl View Post
    Hi, I got the same problem. Everything needs 0 ms to llokup even with ones I tried the first time. Ridiculous! I really want to use this tool. Can anyone offer help?
    A bit late, but I haven't used this tool before. I run 8.04 and had the same problem as you and this solved it for me: pdnsd doesn't honor the settings in /etc/pdnsd.conf if AUTO_MODE is set in /etc/default/pdnsd and it is set to resolveconf by default. I.e. you can change whatever you want in /etc/pdnsd.conf and it will have no effect whatsoever.

    The solution is to comment out AUTO_MODE in /etc/default/pdnsd, then /etc/pdnsd.conf will be used insted of /usr/share/pdnsd/pdnsd-$AUTO_MODE.conf (/usr/share/pdnsd/pdnsd-resolvconf.conf in most cases). You shouldn't edit /usr/share/pdnsd/pdnsd-$AUTO_MODE.conf directly as this file probably will be replaced when the package is upgraded.

    If you want to see if it's actually caching anything you can do a lookup in the cache with pdnsd-ctl dump before and after you have done a dig:

    Code:
    USER @ Computer:~$ sudo pdnsd-ctl dump |grep -i google.com
    [1] USER @ COMPUTER:~$ dig  @localhost google.com mx
    ...
    USER @ Computer:~$ sudo pdnsd-ctl dump |grep -i google.com
    google.com.
    Replace "google.com" with an address you haven't visited. The "[1]" after the first command means that grep couldn't find any hits for the string from the output of pdnsd-ctl dump.

  6. #36
    Join Date
    Jul 2006
    Beans
    18

    Re: HOWTO: Persistant DNS Caching with pdnsd.

    is there any way to use ad-block list with pdsd

  7. #37
    Join Date
    Oct 2008
    Beans
    69
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: HOWTO: Persistant DNS Caching with pdnsd.

    I'd just like to say a big thank you.
    I was wondering why my internet wasn't loading as fast as it did when i used windows, then i stumbled on this. thanks soooo much. My internet is now stupidly fast again
    XFX nForce 790i motherboard, Intel 2.4Ghz quad core, 6GB DDR3 1333 RAM, 2x XFX GeForce 8800GS, 1TB + 500GB + 120GB hard drives, 22" and 15" monitor.
    ALL RUNNING SWEET WITH UBUNTU!

  8. #38
    Join Date
    Aug 2005
    Beans
    293
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: HOWTO: Persistant DNS Caching with pdnsd.

    I'm even lazier so avoided resolvconf by using the magical command:

    Code:
    sudo apt-get --no-install-recommends install pdnsd
    And followed instructions exactly like the first post
    i5-2500, Asus p8p67le, 8g ddr3, gtx460. Eeepc 701 4g surf.

    vm.swappiness=0;noatime,data=writeback;deadline scheduler;preload.

  9. #39
    Join Date
    Mar 2010
    Beans
    1
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: HOWTO: Persistant DNS Caching with pdnsd.

    Quote Originally Posted by Artemis3 View Post
    I'm even lazier so avoided resolvconf by using the magical command:

    Code:
    sudo apt-get --no-install-recommends install pdnsd
    And followed instructions exactly like the first post
    Thats it. Me too. Grate effect on my netbook.

  10. #40
    Join Date
    May 2008
    Location
    Glasgow, Scotland
    Beans
    21
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: HOWTO: Persistant DNS Caching with pdnsd.

    FYI there is a bug registered on Launchpad: pdnsd requires manual restart after new WiFi connection gets established.

    I was having all sorts of problems with this issue and (eventually) came up with the solution I posted there.

    I installed pdnsd and resolvconf and chose the Manual setup when prompted.

Page 4 of 5 FirstFirst ... 2345 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •