1. Cài đặt DNS server với Bind
Thông thường có 2 cách cài đặt là cài từ source và từ gói binary có sẵn của mỗi distro
- Cách 1: Cài bằng rpm
#rpm –ivh bind-9.3.3-10.el5.rpm
#rpm –ivh bind-chroot-9.3.3-10.el5.rpm
Hoặc nếu có internet thì cài bằng yum như sau:
#yum install bind*
- Cách 2: Cài từ source
- Bứơc 1: Lên trang web sau
www.isc.org down về gói có đuôi tar.gz và lưu vào /var/tmp
- Bứơc 2: chuyển đến thư mục chứa file mới down về và giải nén
#cd /var/tmp/
#tar –xvzf bind-version.tar.gz
Thay thế bind-version với tên file down về tại thời điểm hiện tại
- Bứơc 3: Chuyển đến thư mục vừa giải nén và biên dịch nó như sau:
#cd bind-version
#./configure
#make
#make install
2. Cấu hình DNS Master với DNS vnlamp-test.com và IP là 192.168.1.150
- Bước 1: Cấu hình file /etc/named.conf nội dung như sau:
//
// named.conf for Red Hat caching-nameserver
//
acl mynet {
192.168.1.0/24;
127.0.0.1;
};
options {
directory "/var/named";
notify no;
auth-nxdomain yes;
// multiple-cnames yes;
listen-on {
mynet;
};
};
// dump-file "/var/named/data/cache_dump.db";
// statistics-file "/var/named/data/named_stats.txt";
/*
* 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
//
controls {
inet 127.0.0.1 allow { localhost; } keys { rndckey; };
};
zone "." IN {
type hint;
file "named.ca";
};
zone "localdomain" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};
zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 .0.0 .0.0.0.0.0.0.ip6.arpa" IN {
type master;
file "named.ip6.local";
allow-update { none; };
};
zone "255.in-addr.arpa" IN {
type master;
file "named.broadcast";
allow-update { none; };
};
zone "0.in-addr.arpa" IN {
type master;
file "named.zero";
allow-update { none; };
};
include "/etc/rndc.key";
zone "vnlamp-test.com" {
type master;
file "vnlamp-test.com.zone";
allow-query {
mynet;
};
allow-transfer {
mynet;
};
allow-update {
mynet;
};
};
zone "1.168.192.in-addr.arpa" {
type master;
file "1.168.192.in-addr.arpa.zone";
allow-query {
mynet;
};
allow-transfer {
mynet;
};
allow-update {
mynet;
};
};
Bước 2: Tạo file phân giải ngược từ IP ra name như sau:
#vi /var/named/chroot/var/named/1.168.192.in-addr.arpa

Bước 3: Tạo file phân giải thuận từ name ra IP như sau:
#vi /var/named/chroot/var/named/vnlamp-test.com.zone

Bước 4: Khởi động lại DNS server như sau:
#/etc/init.d/named restart
- Bước 5: Chỉ định DNS server bằng cách edit files /etc/resolv.conf như sau:
#vi /etc/resolv.conf
search vnlamp-test.com
nameserver 192.168.1.150
- Bước 6: Sau đó thử một vài query như sau đây:
#nsllookup vnlamp-test.com
#nsllookup smtp.vnlamp-test.com
#nsllookup pop.vnlamp-test.com
# nsllookup 192.168.1.150