Monday, January 09, 2006

Configuring DNS on linux for your LAN Network

How to Configure a DNS

Files You will need to edit to configure a Local DNS on your Lan's are:

/etc/resolv.conf

/etc/host.conf

/etc/named.conf

and you need to create a zone file.

For Eg. /var/named/sriram.com.hosts.

Let me tell Scenario,

I have VMware running on my linux host and Guest OS as Windows Pro 2k

Networking I have used as a Bridged Network.

Ip Address in Linux Host - 10.10.93.x

Ip Address in Windows Guest - 192.168.0.x

Both are 32 Bit Mask.

I have added the gateway and DNS in Windows Guest as 10.10.93.x (Linux Host IP)

Now all I need is :

windows.sriram.com should ping to 192.168.0.x - Win2k Pro

linux.sriram.com should ping to 10.10.93.x - Linux

I am Pasting Below the configuration I have in the above 4 Files.

File 1

/etc/resolv.conf

[root@mybox named]# cat /etc/resolv.conf
#nameserver 202.144.115.4
#nameserver 202.144.66.6
#nameserver 10.10.93.220

nameserver 10.10.93.220

Since it should resolve sriram.com internally I am using My own DNS.

Rest of the DNS Entry I have Hashed.


File 2

/etc/host.conf

[root@mybox named]# cat /etc/host.conf
#order hosts,bind
order bind,hosts
multi on
nospoof on

The order in which you want to resolve. You need to give first preference to bind than to the host file.


File 3

/etc/named.conf

[root@mybox named]# cat /etc/named.conf
// generated by named-bootconf.pl


// secret must be the same as in /etc/rndc.conf
key "key" {
algorithm hmac-md5;
secret
"c3Ryb25nIGVub3VnaCBmb3IgYSBtYW4gYnV0IG1hZGUgZm9yIGEgd29tYW4K";
};

controls {
inet 127.0.0.1 allow { any; } keys { "key"; };
};


options {
pid-file "/var/run/named/named.pid";
directory "/var/named";
/*
* If there is a firewall between you and nameservers you want
* to talk to, you might need to uncomment the query-source
* directive below. Previous versions of BIND always asked
* questions using port 53, but BIND 8.1 uses an unprivileged
* port by default.
*/
// query-source address * port 53;
};

//
// a caching only nameserver config
//
zone "." {
type hint;
file "named.ca";
};

zone "0.0.127.in-addr.arpa" {
type master;
file "named.local";
};


// workaround stupid stuff... (OE: Wed 17 Sep 2003)
zone "ac" { type delegation-only; };
zone "cc" { type delegation-only; };
zone "com" { type delegation-only; };
zone "cx" { type delegation-only; };
zone "museum" { type delegation-only; };
zone "net" { type delegation-only; };
zone "nu" { type delegation-only; };
zone "ph" { type delegation-only; };
zone "sh" { type delegation-only; };
zone "tm" { type delegation-only; };
zone "ws" { type delegation-only; };

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

[root@mybox named]#

I have added the last 4 lines Mentioned in the file.

File 4

Lastly I have Created a Zone file :

/var/named/sriram.com.hosts

[root@mybox named]# cat sriram.com.hosts
$ttl 38400
sriram.com. IN SOA mybox.sriram.com. sriram.gmail.com. (
1136737633
10800
3600
604800
38400 )
sriram.com. IN NS mybox.sriram.com.
windows.sriram.com. IN A 192.168.0.20
linux.sriram.com. IN A 10.10.93.220

Now Reload named, for changes to take effect.

/etc/rc.d/init.d/named reload

Thats it,

[root@mybox named]# ping linux.sriram.com
PING linux.sriram.com (10.10.93.220) 56(84) bytes of data.
64 bytes from mybox.sriram.com (10.10.93.220): icmp_seq=1 ttl=64 time=0.037 ms

[root@mybox named]# ping windows.sriram.com
PING windows.sriram.com (192.168.0.20) 56(84) bytes of data.
64 bytes from 192.168.0.20: icmp_seq=1 ttl=128 time=1.24 ms

If you are finding it difficult to add these entries, than you may try Webmin.

Relatively Webmin is much simple to configure.

In this example I have not talked about Slave, Since we are configuring this in a very small environment Slave is not needed, rather we would take the backup of the files.

No comments: