Tuesday, August 16, 2011

Speed up Internet access with DNS caching Pdnsd

Pdnsd adalah DNS cache proxy yang di buat pertama kali oleh Thomas Moestl dan saat ini di kembangkan oleh Paulus Rombouts. pdnsd ini di configurasi melalui paket configurasi PDNs-CTL. tidak seperti BIND, pdnsd merekam dns cache untuk retensi jangka panjang dan tidak akan membersihkan cache saat startup atau pun saat komputer di matikan. pdnsd di rancang untuk beradaptasi dengan situasi dengan konektivitas internet yang lambat, seperti halnya saat menggunakan fasilitas hostpot/wifi atau internet dial-up seperti mobile broadbrand. program ini juga memiliki kemampuan terbatas bertindak sebagai authoritative nameserver ntuk zona DNS lokal dalam jaringan pribadi. Program ini dirilis di bawah GNU General Public License (GPL). Jadi Gratis ! :D

Intinya pdnsd dapat sangan membantu untuk mempercepat cache dns saat browsing, cara kerjanya yaitu dengan cara me rekam setiap dns yang di resolv dari konfigurasi pdnsd dan saat kita kembali ke halaman yang telah kita kunjungin dns server kita tidak perlu jauh-jauh untuk kembali meresolv ulang halaman web tersebut. :D

Install Pdnsd 
Debian Based 

$ sudo apt-get install pndsd 
Fedora Based 
$ yum install pdnsd 
Setelah menginstal pdnsd configurasi harus dilakukan dengan mengedit konfigurasi file pdnsd.conf yang terdapat pada directory /etc/, ini untuk menentukan Cache DNS Server yang digunakan untuk pencarian.

Edit Configurasi pdnsd 
$ sudo gedit /ete/pdnsd.conf 
Secara default configurasi pdnsd setelah penginstallan.
 
// 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";
}

/* with status_ctl=on and resolvconf installed, this will work out from the box
   this is the recommended setup for mobile machines */
server {
    label="resolvconf";
}

/*
// 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: */

Ubah dan edit configurasi tersebut sesuai dengan kebutuhan kalian. berikut configurasi pdnsd yang telah saya modifikasi sesuai dengan koneksi internet saya yang mengunakan mobile broadband dengan provider Telkom flexi.

global {
        perm_cache=2048;
        cache_dir="/var/cache/pdnsd";
        max_ttl=604800;
        run_as="pdnsd";
        paranoid=on;
#       next setting allows ppp/ip-up update the name servers -- ABa / 20040213
        status_ctl=on;
        neg_rrs_pol=on;
        par_queries=1;
        server_port=53;
        server_ip="127.0.0.1";
}


server {
        ip="203.130.196.5";
        timeout=60;
        interval=900;
        uptest=ping;
        ping_timeout=500;
        proxy_only=on;
        purge_cache=off;
        caching=on;
}
server {
        ip="203.130.206.250";
        timeout=60;
        interval=900;
        uptest=none;
        ping_timeout=500;
        proxy_only=on;
        purge_cache=off;
        caching=on;
}

server {
    label="resolvconf";
}

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

Lihat pada bagia ip=203.130.196.5"; dan juga ip server ke 2 ip=203.130.206.250"; Dapat anda sesuaikan dengan Dns server yang anda inginkan. Jika komputer Anda mendapatkan nameserver dari sebuah server DHCP, Anda perlu mengkonfigurasi ulang dhclient.conf untuk membuat 127.0.0.1 server sebagai domain utama Anda.

Edit configurasi pada dhclient.conf 
$ sudo gedit /etc/dhcp3/dhclient.conf
Hilangkan tanda # atau uncomment pada bagian prepend domain-name-servers 127.0.0.1;
prepend domain-name-servers 127.0.0.1; 
Ubah DNS Server dengan IP local 127.0.0.1 untuk cara mengganti dns server pada linux ubuntu baca DISINI

Restart pdnsd : 
$ sudo /etc/init.d/pdnsd restart
untuk melakukan pengecekan apakah pdnsd telah jalan dapat mengetikan perintah dig dan lihat pada Query time saat resolv pertama dns.
 
abewisnu@Linux:~$ dig google.com

; <<>> DiG 9.7.1-P2 <<>> google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 22657
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 4, ADDITIONAL: 0

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

;; ANSWER SECTION:
google.com.		290	IN	A	209.85.175.106
google.com.		290	IN	A	209.85.175.147
google.com.		290	IN	A	209.85.175.99
google.com.		290	IN	A	209.85.175.103
google.com.		290	IN	A	209.85.175.104
google.com.		290	IN	A	209.85.175.105

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

;; Query time: 455 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Tue Aug 16 20:04:59 2011
;; MSG SIZE  rcvd: 196

Dan untuk ke dua kalianya perintah dig di jalan kan maka Query time menjadi 0 msec.
 
abewisnu@Linux:~$ dig google.com

; <<>> DiG 9.7.1-P2 <<>> google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 33348
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 4, ADDITIONAL: 0

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

;; ANSWER SECTION:
google.com.		275	IN	A	209.85.175.105
google.com.		275	IN	A	209.85.175.106
google.com.		275	IN	A	209.85.175.147
google.com.		275	IN	A	209.85.175.99
google.com.		275	IN	A	209.85.175.103
google.com.		275	IN	A	209.85.175.104

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

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Tue Aug 16 20:05:14 2011
;; MSG SIZE  rcvd: 196

Pndsd membuka port 53 sebagaia dns server. untuk melakukan pengecekan port bisa menggunakan Network tools yang terdapat pada ubuntu atau menggunakan nmap. ini juga perlu di ketahui pdnsd server tidak akan jalan jika terdapat port yang sama.
 
root@Linux:~# nmap -sS 127.0.0.1

Starting Nmap 5.21 ( http://nmap.org ) at 2011-08-16 20:13 WIT
Nmap scan report for localhost.localdomain (127.0.0.1)
Host is up (0.0000050s latency).
Not shown: 996 closed ports
PORT     STATE SERVICE
25/tcp   open  smtp
53/tcp   open  domain
631/tcp  open  ipp
3128/tcp open  squid-http

Nmap done: 1 IP address (1 host up) scanned in 0.15 seconds

Refrensi :
https://wiki.archlinux.org/index.php/Pdnsd
https://help.ubuntu.com/8.04/serverguide/C/index.html

OK...semoga artikel ini bermanfaat. :)

I am a fan of technology and i love coffee. I’m also interested in web programming and networking. below there are some accounts you can follow to contact me.