today i am going to teach how you can add a domain name to your web server using BIND. these is my case:
  • i have a fedora core linux web server with apache and bind9
  • my bind is chroot jailed, if you have a directory called "chroot" in /var/named then you are also chroot jail
  • i have a domain name poitint to my server.
  • i have access to root
  • i have access to linux shell (via ssh)
these are my properties (example)
  1. My domain name: wallpaperama.com
  2. My nameserver for wallpaperama.com is: ns1.wallpaperama.com
  3. My email address is [email protected]
  4. My linux server ip address is: 70.238.57.57
  5. My linux server hostname is: ns1.wallpaperama.com


STEP 1. login to your shell as root

STEP 2. send this command to create our first file called : wallpaperama.com.hosts
nano /var/named/chroot/var/named/wallpaperama.com.hosts
this will open a blank file called wallpaperama.com.hosts with our text editor called nano. you can use vi if you want to, if you want to use vi, then replace the command with: vi /var/named/chroot/var/named/wallpaperama.com.hosts

STEP 3. Now that you have wallpaperama.com.hosts file, add the following information:
$ttl 38400
wallpaperama.com.    IN      SOA     localhost.localdomain. [email protected] (
                        1184045571
                        10800
                        3600
                        604800
                        38400 )
wallpaperama.com.    IN      NS      localhost.localdomain.
www.wallpaperama.com.        IN      A       70.238.57.57

now if you look at the information, all you have to do is replaced the following with your own information:
wallpaperama.com (replace any wallpaperama.com with whatever your DOMAIN NAME is)
[email protected] (replace [email protected] with whatever your EMAIL name is)
70.238.57.57 (replace 70.238.57.57 with whatever your IP ADDRESS name is)
1184045571 (this has to be a unique number you haven't used before. some people use the curretn time and date, for example 200707011535 with is the year = 2007, month = 07, day = 01, hour = 15, minute = 35)
NOTE: its important to you keep the same format as it is on the example above. Make sure you use the same format exactly as it appears above. what i mean by the format is to make sure the { } ; are in the same line as my example, otherwise, when you restart your DNS server, it will fail. i tell you cuz it failed on me once.


STEP 4. Now you need to edit the named.conf file, send this command:
nano /var/named/chroot/etc/named.conf
it should look something like this:
options {
        directory "/etc";
        pid-file "/var/run/named/named.pid";
        };

zone "." {
        type hint;
        file "/etc/db.cache";
        };

zone "anydomain.com" {
        type master;
        file "/var/named/anydomain.com.hosts";
        };

STEP 5. now you need to edit named.conf to add your domain name. so in my example, i will be adding wallpaperama.com and now, this is how named.conf should look like:
options {
        directory "/etc";
        pid-file "/var/run/named/named.pid";
        };

zone "." {
        type hint;
        file "/etc/db.cache";
        };

zone "anydomain.com" {
        type master;
        file "/var/named/anydomain.com.hosts";

zone "wallpaperama.com" {
        type master;
        file "/var/named/wallpaperama.com.hosts";
        };
As you can see all i did was added wallpaperama.com at the bottom of the file:
type master; (this is a master zone )
file "/var/named/wallpaperama.com.hosts"; (this is the location of the file where we created the wallpaperama.com.hosts on STEP 4.
NOTE: make sure you use the same format exactly as it appears above. what i mean by the format is to make sure the { } ; are in the same line as my example, otherwise, when you restart your DNS server, it will fail. i tell you cuz it failed on me once.

STEP 6. Now that you have all the correct files, you will need to restart your DNS server for the changes to take affect. so restart your DNS server with the following command:
/etc/init.d/named restart


Now open your website on your browser and you should see your webserver.

this is what i got:

fedora test page

Ok, the next step would be to point to a directory specially for my domain instead of getting the default apache page right.

so this is how you do it: click on this link on how to add virtual domain names in apache server