Friday, November 21, 2008

sample dns linux setup

In a small test environment using two CentOS 5.2 default installs, I was able to get dns to work between the two (one client, one server).

On the Server:
First make sure the following is installed (rpm -qa | grep "bind"):
  • caching-nameserver
  • bind
  • bind-utils
  • bind-chroot
  • bind-libs
Just use yum -y install bind if necessary....

edit or create the following files (keep in mind the IPs and domains are tested and can be changed to your preferred):

- /etc/named.caching-nameserver.conf -> /var/named/chroot/etc/named.caching-nameserver.conf
Located HERE with indentations
============================================
options {
listen-on port 53 { any; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";

// Those options should be used carefully because they disable port
// randomization
query-source port 53;
// query-source-v6 port 53;

allow-query { any; };
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
#view localhost_resolver {
# match-clients { localhost; };
# match-destinations { localhost; };
# recursion yes;
# include "/etc/named.rfc1912.zones";
#};

include "/etc/named.rfc1912.zones";

zone "mydomain.com" IN {
type master;
file "named.my-hosts";
allow-update { none; };
};

zone "1.168.192.in-addr.arpa" IN {
type master;
file "named.my-rev";
allow-update { none; };
};
==============================================




Your Ad Here



- /var/named/named.my-hosts -> /var/named/chroot/var/named/named.my-hosts
Located HERE with indentations
===============================================
$TTL 86400
@ IN SOA host.mydomain.com. root.host.mydomain.com. (
42 ; serial
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
@ IN NS host.mydomain.com.
host IN A 192.168.1.5
host2 IN A 192.168.1.2
================================================

- /var/named/named.my-rev -> /var/named/chroot/var/named/named.my-rev
Located HERE with indentations
================================================
$TTL 86400
@ IN SOA host.mydomain.com. root.host.mydomain.com. (
42 ; serial
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
@ IN NS host.mydomain.com.
5.1.168.192.in-addr.arpa. IN PTR host.mydomain.com.
2 IN PTR host2.mydomain.com.
================================================

- /etc/resolv.conf
================================================
search mydomain.com
nameserver 192.168.1.5
================================================

On the Client:

- /etc/resolv.conf
================================================
search mydomain.com
nameserver 192.168.1.5
================================================


To test your configuration:

Enter the command "nslookup -sil" and press ENTER. At the ">" prompt, type "server" and press ENTER. If you edited the file "/etc/resolv.conf" properly, you should get the following output:
>server
Default server: 192.168.1.5
Address: 172.16.1.5#53
>
you may need to modify your firewall settings and don't forget to start the services
service bind start


No comments: