Friday, 2 December 2011

PDNSD How To - A DNS caching personal server

PDNSD is a non authoritative Caching DNS server. It maintains a disk cache of the queries that you system performs and subsequent queries will be faster from the cache. It is safe enough to be use on a personal Unix/Linux system as a home Desktop or a Laptop.
Info about its history, current developer Paul Rombouts and other technical info can be see here http://www.phys.uu.nl/~rombouts/pdnsd.html.

Versions and OS:
OS: Fedora 16 x86_64
PDNSD: 1.2.8 RPM

Downloads:
Fedora 12,13,14,15,15. This should also work with RHEL and Cent OS
PDNSD i386 RPM
PDNSD_x86_84 RPM


Source tar:
PDNSD-1.2.8 SRC RPM
PDNSD-1.2.8 SRC TAR BALL

Debian
PDNSD

Free BSD
PDNSD

Gentoo
PDNSD

Network Requirements:
Your system supports the local interface 'lo' with a 127.0.0.1 ip. This is a standard for all computers irrespective of what OS it is.

A query able DNS server, e.g. your ISP's DNS, OpenDNS, or your ADSL Router if it has got a DNS server.

Necessary firewall configuration that allows DNS query from your system to the forwarding or authoritative DNS server

Login to start and stop network services.


Installation:
The Downloaded RPM's can be installed with yum. login as root and use the shell terminal and run the commands below. Yum should take care of any missing dependencies.

#yum localinstall pdnsd-1.2.8-par_el5.x86_64.rpm

If you are using the source tar then

#cd <path to the pdnsd source folder>
#./configure
#make
#make install

The files are installed to /usr/local/bin and a pdnsd.conf is copied to the /etc folder.

Configuration:
Your systems DNS configuration and pdnsd.con require amendments as below.

pdnsd.conf
Use a editor like vi to edit the pdnsd.conf file Two sections need changing for the server to serve DNS queries. Leave the remaining sections as is.


global {
        perm_cache=16384; - this is in kB, increase it if you want more disk cacheing
        server_ip = 127.0.0.1; this is the local 'lo' network interface
        paranoid=on; A security feature to avoid cache poisoning 
}
Let other options be defaults.

server {
        ip = som.eip.add.ress;  Put your ISP's DNS-server address(es) here.
        uptest = query;     Test if the network interface is active. The above DNS is queried with a DNS request
        interface=eth0;     The interface connected to the network.
}

Other options in the config file will be as is and change not required.

resolv.conf
In different Unix / Linux flavours, different files and configuration used. resolv.conf is the most common dns setting in a Unix / Linux system. Comment out all existing nameservers and add

nameserver 127.0.0.1

Start Service and Test:
The installation has installed a service that needs to be started and used. Also set the service to start up a boot.

#chkconfig --levels 3456 pdnsd on
#service start pdnsd

To test
# nslookup google.com
Server:        127.0.0.1
Address:    127.0.0.1#53

Non-authoritative answer:
Name:    google.com
Address: 74.125.230.148
Name:    google.com
Address: 74.125.230.144
Name:    google.com
Address: 74.125.230.146
Name:    google.com
Address: 74.125.230.147
Name:    google.com
Address: 74.125.230.145

If there is a error check is the service status, network connectivity, the up DNS server, pdnsd status with

#pdnsd-ctl status

This is a great software for internal LAN, laptops and desktops where the dns query takes a long time and speeds up internet browsing and limits the network DNS traffic to minimal.

I personally use it with my laptop. Its very nice and has a minimal maintenance. 

-Bellamkonda Sudhakar

VSFTPD Virtual Users creation BASH Script How To

The BASH scripts presented here are for the VSFTPD server that has been setup using the how to article here http://sudhakarbellamkonda.blogspot.com/2011/11/vsftpd-virtual-users-and-shell-users.html

Do these changes before using the scripts assuming that you have root access.

Create the following vuser subfolder in /etc/vsftpd/ if not done already

#cd /etc/vsftpd
#mkdir vuser


Download the scripts bundle and untar then in /etc/vsftpd/vuser folder
Click here to download http://www.mediafire.com/?j9anm89c8v6pt84
Latest versions and info maintained at vsftpd-virtualuser-bash-scripts 

The scripts:
vuserchk - checks the necessary files and folders necessary for these scripts
vuser.conf - the file containing configuration parameters for these scripts
vuseradd - adds a virtual user
vuserdel - delets a virtual user
vuserres - restores a deleted user
vuserpas - changes a virtual user password
vusersho - displays the user password

The scripts are very verbose and will display messages and errors which are self explanatory.


What the scripts not do:
Deleting a user will remove the user from the active list and the ftp home folder is renamed to $USER-deleted and the deleted user details are copied to a user deleted list. A script to archive and move the tarball to an archive folder is on the back burner.

Panic not be Cautious: Use the scripts wisely and carefully. Please backup before any use at production servers. The scripts have been tested and used without any errors or problems.

Six are the scripts: These scripts are very non intrusive and have a simple logic flow. Prerequisites are BASH, GAWK, SED for the scripts to work. I am hoping to introduce more functionality into the scripts and add a local user ftp home sync'er and a deleted folder archiver, once finished will add them here.

Test them, deploy for ease of mind and relax and let the scripts do the work :).