Friday, July 30, 2010

Alias with arguments (BASH,CSH)

A neat way to make your life abit easier in Linux/Unix is using aliases, but how do you use an alias with an argument?
Let's say you want make a special "change directory" (we will call it cdd) command that will also display your current position in the file system tree.

Bash uses $1,$2,$3..etc for passed arguments, so we will add a little function inside our .bashrc file that will accomplish this mission:

cdd () { cd ${1} ; echo $PWD ; }

In C shell thing are little bit different, this will achieve the same effect when put into .cshrc:

alias cdd 'cd \!*;echo $cwd;'

Wednesday, July 14, 2010

Installing & Configuring Bind 9 (Ubuntu/Debian)

Numerous articles have been written about bind9, most of them are long, clumpy and not really explain how things work in detail. In this fairly short article I will try to give my point of view and make thing a bit more clear especially for new admins, so lets start!

First install bind9:

#apt-get install bind9

Next, open /etc/bind/named.conf.local, here you will need to add your zone name + the appropriate zone db file.
You will also need to add reverse look zone + db file (for reverse lookups), this is how your file will generally look like. 

* Note:I've used subnet in my case:

#vi /etc/bind/named.conf.local

zone "linux.lan" {
type master;
file "/etc/bind/zones/linux.lan.db";

zone "" {
type master;
file "/etc/bind/zones/";

Next, add your ISP's DNS server to /etc/bind/named.options as a forwarder, This means is when your DNS server will not know the answer it will query the forwarder and provide a non-authoritative answer.

Create the directory that will contain the zones db:

# mkdir /etc/bind/zones

Create the db file:

#vi /etc/bind/zones/linux.lan.db 

linux.lan. IN SOA dns1.linux.lan. admin.linux.lan. (

38400 )

linux.lan. IN NS dns1.linux.lan.
dns1 IN A

It's time to create a reverse zone db-file, pay attention that the servers PTR record has 7, that stands for

#vi /etc/bind/zones/

@ IN SOA linux.lan. admin.linux.lan. (
86400 );

IN NS dns1.linux.lan.
7 IN PTR linux.lan.

Next, restart bind to changes to take effect:

# /etc/init.d/bind9 restart

To make searches more convinient, you can (and should) add your domain suffix to /etc/resolv.conf

#echo "search linux.lan" >> /etc/resolv.conf

Test your DNS via host,nslookup or dig commands:

#host dns1
dns1.linux.lan has address

Works like magic!