Showing posts with label DNS. Show all posts
Showing posts with label DNS. Show all posts

Wednesday, August 20, 2008

Well, does pdnsd make browsing faster?

After at least 14 hours of browsing in Ubuntu on the MacBook with pdnsd turned on, my conclusion is that I just cannot at all see any evidence for faster browsing. Honestly, to me it looks exactly the same, no slower and no faster.
And yes, I am sure that pdnsd is running and the selected DNS server is 127.0.0.1. Here's what I get from nslookup:

$ nslookup google.com
Server: 127.0.0.1
Address: 127.0.0.1#53

Non-authoritative answer:
Name: google.com
Address: 64.233.167.99
Name: google.com
Address: 72.14.207.99
Name: google.com
Address: 64.233.187.99


So, this is disappointing. Nevertheless, given that pinging my usual DNS servers only took 65 ms, that doesn't provide much leeway for speeding up page retrieval.
I'm really going to have to try and find out if others REALLY are getting faster browsing?
On the same topic, here are two interesting articles from SourceForge. The first covers how DNS works in Linux and the second looks at a more elaborate local DNS server setup for the purpose of, yes, speeding up browsing.

Tuesday, August 19, 2008

Use a local DNS server to speed up browsing

Well, this sounds like a good idea. After all, we would all prefer to have any clicked link or icon or speeddial applet cause the desired webpage to show up as near to instantaneously as possible.
As all of the usual means of calling up a webpage involve adding a "word" address to the address bar, the first stop nearly always has to be to the DNS server to translate those words into the numbers which the computer can understand.
So, how long does this take?
I use OpenDNS (208.67.222.222 and 208.67.220.220) and if I ping either of these, I get a reply after about 65 ms. So, if I could use a local DNS server that allowed me to retrieve the IP address of the webpage I could perhaps save up to 65 ms of time per page.
If page typically takes 2 seconds to open, am I really going to notice if it opens 0.065 seconds more quickly? I really don't think so.
What I'm not sure of in this scenario is how long the OpenDNS servers take to find the IP of the web address compared to how long it would take to retrieve the same information from a small local cache.
So, there may be a possibility here to speed up my browsing so I though I'd give it a try.

The first one I tried was dnsmasq which is available in the Hardy repos. I used this guide.
The installation and configuration went smoothly (I listened to 127.0.0.1) but trying to retrieve a new web page was intolerably slow and sometimes didn't happen at all. Seemingly, when nothing relevant was in the LocalHost cache, it didn't then look in the OpenDNS servers (although I didn't have these included in /etc/resolv.conf -- only 127.0.0.1 here -- 208.67.222.222 and 208.67.220.220 are the DNS servers in my router).
Certainly, running, for example, dig google.com showed the 127.0.01 was being used as the DNS server. Also, the first attempt at this gave maybe up to 300 ms as the retrieval time, the second time gave typically 0-2 ms retrieval which is certainly a vast improvement.
Unfortunately, these encouraging results did not translate themselves into good browsing performance. Indeed, browsing became almost impossible.
There are several other howtos on dnsmasq for Ubuntu such as this and this, but nothing I found allowed me to eliminate this problem.
Also, because dnsmasq saves the cache to RAM, this means that you have to start building your cache again after a reboot -- which means slow browsing until all your usual page have been called up at least once.
Given these disadvantages, I decided to give pdnsd a try. This saves the cache to disk so it's not lost.

I first used this guide but this simply didn't work. In trying to start pdnsd, I consistently got an error about the absence of the file

/etc/cache/pdnsd/pdnsd.status

which indeed was not present.
Also, I could't find any reference to the absence of this file in google.
So, next I tried this Ubuntu howto although I first tried the guide in this post from much later in this thread.
This however, didn't give a working pdnsd as this command
$ sudo /etc/init.d/pdnsd restart

always gave an error on the start part of the command.
Finally, I tried the guide in post #1 and this worked without problems.
What I did was as follows:

sudo apt-get install pdnsd
##I did NOT install resolvconf
sudo gedit /etc/pdnsd.conf


My /etc/pdnsd.conf is given here:

// Read the pdnsd.conf(5) manpage for an explanation of the options.

/* Note: this file is overriden by automatic config files when
/etc/default/pdnsd AUTO_MODE is set and that
/usr/share/pdnsd/pdnsd-$AUTO_MODE.conf exists
*/

global {
perm_cache=1024;
cache_dir="/var/cache/pdnsd";
run_as="pdnsd";
server_ip = 127.0.0.1; // Use eth0 here if you want to allow other
// machines on your network to query pdnsd.
status_ctl = on;
paranoid=on;
// query_method=tcp_udp; // pdnsd must be compiled with tcp
// query support for this to work.
min_ttl=15m; // Retain cached entries at least 15 minutes.
max_ttl=1w; // One week.
timeout=10; // Global timeout option (10 seconds).

// Don't enable if you don't recurse yourself, can lead to problems
// delegation_only="com","net";
}


server {
label=OpenDNS;
ip=208.67.222.222;
ip=208.67.220.220;
timeout=30;
interval=30;
uptest=ping;
ping_timeout=50;
purge_cache=off;
}

// This section is meant for resolving from root servers.
server {
label = "root-servers";
root_server=on;
ip = 198.41.0.4
, 192.228.79.201
, 192.33.4.12
, 128.8.10.90
, 192.203.230.10
, 192.5.5.241
, 192.112.36.4
, 128.63.2.53
// , 192.36.148.17
// , 192.58.128.30
// , 193.0.14.129
// , 198.32.64.12
// , 202.12.27.33
;
timeout = 5;
uptest = query;
interval = 30m; // Test every half hour.
ping_timeout = 300; // 30 seconds.
purge_cache = off;
exclude = .localdomain;
policy = included;
preset = off;
}


source {
owner=localhost;
// serve_aliases=on;
file="/etc/hosts";
}

rr {
name=localhost;
reverse=on;
a=127.0.0.1;
owner=localhost;
soa=localhost,root.localhost,42,86400,900,86400,86400;
}

/*
neg {
name=doubleclick.net;
types=domain; // This will also block xxx.doubleclick.net, etc.
}
*/

/*
neg {
name=bad.server.com; // Badly behaved server you don't want to connect to.
types=A,AAAA;
}
*/

/* vim:set ft=c: */

I will admit that I have no idea why the root-servers section is required particularly as the servers involved have no relevance to my setup. I'll try a test where I take this section out.

Next, I amended /etc/dhcp3/dhclient.conf where I took out the line
prepend domain-name-servers 208.67.222.222, 208.67.220.220;

and added
prepend domain-name-servers 127.0.0.1;

Now I rebooted (and this seems to be important and started pdnsd with this
sudo /etc/init.d/pdnsd restart

and it started without a hitch.
Now everything worked perfectly. For example
dig google.com

gives this
; <<>> DiG 9.4.2-P1 <<>> google.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 44898
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 4, ADDITIONAL: 4

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

;; ANSWER SECTION:
google.com. 855 IN A 72.14.207.99
google.com. 855 IN A 64.233.187.99
google.com. 855 IN A 64.233.167.99

;; AUTHORITY SECTION:
google.com. 172704 IN NS ns1.google.com.
google.com. 172704 IN NS ns2.google.com.
google.com. 172704 IN NS ns3.google.com.
google.com. 172704 IN NS ns4.google.com.

;; ADDITIONAL SECTION:
ns1.google.com. 172704 IN A 216.239.32.10
ns2.google.com. 172704 IN A 216.239.34.10
ns3.google.com. 172704 IN A 216.239.36.10
ns4.google.com. 172704 IN A 216.239.38.10

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Aug 20 00:23:44 2008
;; MSG SIZE rcvd: 212

Note that the first time I used dig google.com, the Query time was something quite high (350 ms) but the second time it reverted to 0 ms presumably because of the local DNS cache.
Another useful command is
sudo pdnsd-ctl server OpenDNS retest

which gives this output
Opening socket /var/cache/pdnsd/pdnsd.status
Succeeded

and
sudo pdnsd-ctl status

which gives this output
pdnsd-1.2.6-par running on ubuntu-mac.

Cache status:
=============
1024 kB maximum disk cache size.
133062 of 1058816 bytes (12.6%) memory cache used in 513 entries.

Thread status:
==============
server status thread is running.
pdnsd control thread is running.
tcp server thread is running.
udp server thread is running.
476 query threads spawned in total (0 queries dropped).
0 running query threads (0 active, 0 queued).

Configuration:
==============
Global:
-------
Cache size: 1024 kB
Server directory: /var/cache/pdnsd
Scheme file (for Linux pcmcia support): /var/lib/pcmcia/scheme
Server port: 53
Server ip (0.0.0.0=any available one): 127.0.0.1
Ignore cache when link is down: off
Maximum ttl: 604800
Minimum ttl: 900
Negative ttl: 900
Negative RRS policy: auth
Negative domain policy: auth
Run as: pdnsd
Strict run as: on
Use NSS: on
Paranoid mode (cache pollution prevention): on
Control socket permissions (mode): 600
Maximum parallel queries served: 40
Maximum queries queued for serving: 60
Global timeout setting: 10
Parallel queries increment: 2
Randomize records in answer: on
Query method: udp_only
Query port start: 0
Query port end: 65535
TCP server thread: on
TCP query timeout: 30
Delegation-only zones: (none)
Server 0:
------
label: OpenDNS
ip: 208.67.222.222
server assumed available: yes
ip: 208.67.220.220
server assumed available: yes
port: 53
uptest: ping
timeout: 30
uptest interval: 30
ping timeout: 50
ping ip: (using server ip)
interface:
device (for special Linux ppp device support):
uptest command:
uptest user: (process owner)
force cache purging: off
server is cached: on
lean query: on
Use only proxy?: off
Assumed root server: no
Randomize server query order: no
Default policy: included
Policies: (none)
Server 1:
------
label: root-servers
ip: 198.41.0.4
server assumed available: yes
ip: 192.228.79.201
server assumed available: yes
ip: 192.33.4.12
server assumed available: yes
ip: 128.8.10.90
server assumed available: yes
ip: 192.203.230.10
server assumed available: yes
ip: 192.5.5.241
server assumed available: yes
ip: 192.112.36.4
server assumed available: yes
ip: 128.63.2.53
server assumed available: yes
port: 53
uptest: query
timeout: 5
uptest interval: 1800
ping timeout: 300
ping ip: (using server ip)
interface:
device (for special Linux ppp device support):
uptest command:
uptest user: (process owner)
force cache purging: off
server is cached: on
lean query: on
Use only proxy?: off
Assumed root server: yes
Randomize server query order: no
Default policy: included
Policies:
exclude: .localdomain.
Succeeded

The big question, of course, is "is browsing any faster"? Well, it's certainly not a whole lot slower. However, I have the impression that pages which are opened for the first time are just a little bit slower than they would have been with the OpenDNS servers alone. Thereafter, I believe they might be just a shade faster.
I have the impression that I should not have stopped prepending the servers 208.67.222.222 and 208.67.220.220 from /etc/dhcp3/dhclient.conf as now, these servers are missing from /etc/resolv. I believe that when 127.0.0.1 can't resolve the address, the OpenDNS servers should then be used to do the resolving and thereby avoid untoward delays with pages whose adresses are not yet in the cache.
Nevertheless, I believe I would need a few days of browsing to get a better feel for whether or not there is a performance boost.

Thursday, August 07, 2008

More problems with Intrepid Alpha 3

After shutting down Intrepid (MacBook) with apparently everything functioning normally, this morning's stratup was less rosy.
Although it booted, it kept going to a black screen just after the Initial screen (with progress bar) dissappeared. So, couldn't ever login. Thought I was looking at another re-install.
But no, went to Recovery Mode in the boot menu and this gave me a list of recovery options (this is an upgrade from just the TTy1 console screen which was the only thing available historically).
Chose the Fix X Server (or something) option. Then when it had done this, I chose, boot and everything worked fine.
Same problem in later attempts, but after 2-3 blackscreens it eventually booted as normal.
Another problem I see now, is that the internet connection seems extremely slow. As usual this is a DNS problem. Despite having changed /etc/dhcp3/dhclient.conf to prepend the OpenDNS servers, I only have 192.168.1.254 as the only available DNS server on both my wired and my wireless connections to Intrepid.
Worse, there is NO network option available in Systems>>Administration. So, no other way to change DNS servers.
Wonder when this will be fixed.

Saturday, July 26, 2008

Set preferred DNS servers in Router

After every new OS install, one of the first things I do is to look for something like /etc/dhcp3/dhclient.conf and prepend my preferred DNS servers.
Sometimes this option isn't available and I've gone as far as manually editing /etc/resolv.conf and then making this file immutable (which has messed up at least one update for me).
After reviewing what I'd seen written on this topic, today I went onto my Netopia 3347nwg router and did this:
1. Enter Expert Mode
2. Click on Configure and Connection
3. Add the IP's for the preferred primary and secondary DNS servers.
4. Save and exit.

Although this sounds right and has worked fine for me up to now, I'm not sure still. My router has ALWAYS featured the ISPs DNS servers which work fine. The problem I get arises when the only DNS server chosen is 192.168.1.254 (defaults gateway). This really slows down browsing.
I really cannot see that what I did can avoid the dreaded 192.168.1.254 showing up so I don't as yet see myself getting away from prepending the preferred DNS servers.

Wednesday, January 30, 2008

Installing Mepis 7.0 on MacBook

OK, today I put Mepis 7.0on my Seagate 250GB usb HDD which is currently hooked up to the MacBook.
One thing I had forgotten about Mepis is that they seem to prefer to boot it WITHOUT the initrd kernel file. However, you are asked to choose if you want initrd or not during the installation. Nevertheless, initrd is claimed to be only for experts so that most people would shy away from it.
However, when I did try to boot to Mepis from the MacBook, I almost immediately got a kernel panic.
I figured the only thing that could be wrong was the lack of initrd (I've never booted to an OS on a usb HDD without initrd) so I re-installed Mepis and this time asked for initrd booting.
So then I included initrd.img-2.6.22.xxx-mepis along with the vmlinuz equivalent in /boot/mepis/ on the Ubuntu partition on the Mac internal HDD and changed the /boot/grub/menu.lst to look like this:

title MEPIS at sdb7, kernel 2.6.22-1-mepis-smp
root (hd0,2)
kernel /boot/mepis/vmlinuz-2.6.22-1-mepis-smp root=/dev/sdb7 nomce quiet splash vga=791 resume=/dev/sdb1
initrd /boot/mepis/initrd.img-2.6.22-1-mepis-smp
boot

This booted fine with no problems.
Its interesting that Mepis seem to want to simplify the boot process by specifying a "variable" vmlinuz which might me the "latest" or the "previous" kernel version. This is presumably to allow people to select one or the other which would then be automatically updated without them having to do anything.
Nevertheless, I chose the "older" method of using a specific vmlinuz together with a specific (and, of course, matching) initrd.img.

As usual, when I start with a new OS arrangement, I need time to overcome the inevitable problems with wireless, desktop effects and maybe sound and video.
I haven't gotten around to even looking at any of these on Mepis as I'm amazingly having a problem with wired Internet connection.
At first, the wired was there and I could browse without problems.
Then I messed around with MEPIS Network Assistant to try to set my static DNS requirements and to try to get wireless setup. However, almost immediately after doing this, I could no longer browse - just getting Remote server unreachable errors. Despite this, I can still ping. So this is very weird but I remember having a similar problem before on some other OS but can't remember any of the details. I think it may have been a kind of DNS problem.
Anyway, I've posted on the MepisLovers forum and some people are helping me. If I can't get this solved I'm going to re-install Mepis tomorrow.