Archive for July, 2011

I’m a bit stressed for time, so i’ll keep this nice and short. The whole article will be a series of points.

  • Almost ALL bind config files are basic text files.
  • Spaces and special ending characters are VERY important.
  • Serial numbers within the files (you will see shortly) do NOT effect greatly, but it is best practice to keep them in order.
  • Serial numbers SHOULD be incremented everytime you edit the file
  • Forward lookup files are usually stored in /etc/bind
  • Naming of the file should be [domain-name].db  for example: geekdomain.db, google.db
Here’s a Sample forward lookup file:  (Note, all lines starting with ; are comments)

; As a basic RULE, all config files HAVE to start with the SOA (Start Of Authority) line.
; The SOA tells us which server is the Authoritative DNS server for this domain. If this is your ONLY DNS server, this will be your Authoritative server. Lets di-sect the stuff within the ().
; The serial number, is a number representing which version this file is. The numbering convention is upto the admin. We normally type the serial number as date & time. For example,
; if we edit this file on the 17th of May 2011, we will number it 20110517. If you want you can put the time in there as well. You must remember to change this number everytime you make any
; change to the file. 
; The next line tells us the refresh rate.  The numbers are in seconds. Hence 3600 gives us a refresh time of 1 hour
; The next line tells us the retry rate. Again, the numbers are in seconds.
; The Next line tells us the expiry time.
; The next line is the minimum time.
    ; Alot of people get confused by this first line. It's simply; @ IN SOA(Saying this server is the SOA) (with the @ sign replaces by a . )
    @ IN SOA geek.domain.  admin.geek.domain. (
	20110517	; Serial number
	3600		; 1 hour refresh
	300		; 5 minutes retry
	172800		; 2 days expiry
	43200 )		; 12 hours minimum

; List of Name servers in this domain. It MIGHT be a good idea to also have your ISP's DNS server in here.
	IN NS		geek.domain.
	IN NS		isp.geek.domain.gk.

; List all MX (Mail exchange) records here!
	IN MX		mail.geek.domain.

; List all your other servers and machines here
    web.geek.domain.            IN A   ; Web Server
    fileserver.geek.domain.     IN A   ; File Server
    machine1.geek.domain.       IN A   ; Windows XP machine

; Alias names
    www	        IN CNAME	web.geek.domain.
    ftp		IN CNAME	fileserver.geek.domain.
    printer	IN CNAME	fileserver.geek.domain.

How to fit all this in with your Bind server (If you came here from my other tutorial):

Goto /etc/bind
Create a text file there named [domain-name].db  for example: geekdomain.db
Type in (or copy paste & edit) the above code according to your needs.
Save the file.
Restart Bind:
/etc/init.d/bind9 restart

How to test if your look up tables are working.

In bash type in :
for example:
nslookup fileserver.geek.domain

We need:

  1. One Vanilla Installation of Ubuntu 10.0 (any version should still work fine)
  2. Machine with enough hard disk space (i used about 10gb for a NON-production testing only machine)
  3. A working internet connection

Lets get started.

*quick note, i have a GUI installed in this box (XFCE) this is absolutly NOT necessary (and most of the time NOT recommended for actual servers)

Set up your Server’s Hostname properly:

to view your current hostname: cat /etc/hostname

cat is a util used to print text out to standard out from a text file. /etc/hostname is where the hostname of the computer is stored.

Viewing Hostname

How to View your Hostname

To set a Host-name simply:

echo “YOUR-HOST-NAME-HERE” > /etc/hostname

echo is a program to repeat what you types into standard out. The “>” sign is for porting information in linux. Here we port that information into the file “/etc/hostname”

How to set the Host-name in your Computer

Setting a custom host-name in your Computer

Set your Domain preferences:

to view your current settings:    cat /etc/resolv.conf

to set a new domain:    echo “domain geek.local” > /etc/resolv.conf

Viewing and Setting your Resolv.Conf

Setting up your Network Settings:

Now normally, in a real life situation you’d have a Static IP for your DNS server (this isnt a recommendation this is a MUST). However, personally i’m setting this up on a Vritual Machine, which means i have to switch between  connecting the server to my REAL network and to my virtual network. What does this mean for us? We basically need to be a wizzz at changing your network settings on the fly!

Here’s the quick Run down:

Viewing your Current Network Settings:

ifconfig -a

This will basically show you all your currently set network settings. Dont get confused by the “lo” interface. That’s the local loop interface in Linux.

Viewing your Network configurations

To set a static IP on your network interface:

ifconfig <interfacename> <ip-address> netmask <network-mask/subnet mask>

eg. ifconfig eth0 netmask

Setting a Static IP for a selected Network Interface

To get IP settings automatically from a DHCP server

dhclient <interface-name>

e.g. dhclient eth0

Getting down Network Configuration settings from a DHCP server

Installing BIND9 and other Necessary Tools

1. Make sure your server is connected to the internet

2. sudo apt-get update

sudo apt-get update

3. sudo apt-get install bind9 dnsutils

Installing BIND9 & DNSUTILS

If everything went well, you should see this message:


Setting up Forward-look-up files and reverse look-up files will be posted shortly!