/etc/named.conf 파일에서
options {
listen-on port 53 { 192.168.100.1; }; <=== 이부분 수정
// 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";
allow-query { localhost; };
recursion yes;
};
나머지는 그대로...
/etc/named.rfc1912.zones 파일에서는
// Config Primary DNS
zone "localhost.localdomain" IN {
type master;
file "named.localhost";
allow-update { none; };
};
zone "localhost" IN {
type master;
file "named.localhost";
allow-update { none; };
};
zone "1.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.loopback";
allow-update { none; };
};
zone "1.0.0.127.in-addr.arpa" IN {
type master;
file "named.loopback";
allow-update { none; };
};
zone "0.in-addr.arpa" IN {
type master;
file "named.empty";
allow-update { none; };
};
// Add test domain
zone "test.co.kr" IN {
type master;
file "test.hosts";
};
zone "100.168.192.in-addr.arpa" IN {
type master;
file "192.168.100.rev";
};
[/var/named/chroot/var/named]# cat test.hosts
$TTL 86400
@ IN SOA ns.test.co.kr. root.test.co.kr. (
2009030300 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS ns.test.co.kr.
ns IN A 192.168.100.1
www IN A 192.168.100.2
ftp IN A 192.168.100.3
blog.test.co.kr. IN A 192.168.100.4
[/var/named/chroot/var/named]# cp test.hosts 192.168.100.rev 복사하여
아래처럼 수정하면 된다.
[/var/named/chroot/var/named]# cat 192.168.100.rev
$TTL 86400
@ IN SOA ns.test.co.kr. root.test.co.kr. (
2009030300 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS ns.test.co.kr.
1 IN PTR ns.test.co.kr.
2 IN PTR www.test.co.kr.
3 IN PTR ftp.test.co.kr.
4 IN PTR blog.test.co.kr.
[/var/named/chroot/var/named]#
그런다음 아래처럼 /var/named 디렉토리에 링크를 건다.
cd /var/named 로 이동후
[/var/named]# ln -s /var/named/chroot/var/named/test.hosts test.hosts
[/var/named]# ln -s /var/named/chroot/var/named/192.168.100.rev 192.168.100.rev
[/var/named]#
[/var/named]# ifconfig eth0:1 192.168.100.1 <== dns ip 를 올려주어야 한다.
그렇지 않으면 dns 서버에 접속할수 없으므로 도메인 질의를 할수 없다.
[/var/named]# cat /etc/resolv.conf
;nameserver 168.126.63.1 <== 기존의 찾을 dns 는 주석처리하고
nameserver 192.168.100.1 <== 자신이 만든 dns 를 등록한다.
[/var/named]#
여기까지 완료되었으면
[/var/named]# ping 192.168.100.1 ; dns 가 살아있는지 확인.
PING 192.168.100.1 (192.168.100.1) 56(84) bytes of data.
64 bytes from 192.168.100.1: icmp_seq=1 ttl=64 time=0.144 ms
64 bytes from 192.168.100.1: icmp_seq=2 ttl=64 time=0.096 ms
^C
[/var/named]# service named start <== dns 가 이미 올라와 있는 상태이면
(service named restart 하여야 한다)
named 시작 중: [ OK ]
[/var/named]#
[/var/named]# nslookup www.test.co.kr
Server: 192.168.100.1
Address: 192.168.100.1#53
Name: www.test.co.kr
Address: 192.168.100.2
[/var/named]# nslookup ftp.test.co.kr
Server: 192.168.100.1
Address: 192.168.100.1#53
Name: ftp.test.co.kr
Address: 192.168.100.3
[/var/named]# nslookup 192.168.100.3
Server: 192.168.100.1
Address: 192.168.100.1#53
3.100.168.192.in-addr.arpa name = ftp.test.co.kr.
[/var/named]#
* 테스트가 잘됨을 알수 있다.
그런데 잘 안되면...
아래처럼 로그 파일을 확인해서 에러를 찾고 고쳐서 dns 서버를 재구동 하여야 한다.
[/var/named]# tail -10 /var/log/messages
Feb 21 02:23:29 fedora165 named[5644]: zone 0.in-addr.arpa/IN: loaded serial 0
Feb 21 02:23:29 fedora165 named[5644]: zone 1.0.0.127.in-addr.arpa/IN: NS '1.0.0.127.in-addr.arpa' has no address records (A or AAAA)
Feb 21 02:23:29 fedora165 named[5644]: zone 1.0.0.127.in-addr.arpa/IN: loaded serial 0
Feb 21 02:23:29 fedora165 named[5644]: zone 100.168.192.in-addr.arpa/IN: loaded serial 2009030300
Feb 21 02:23:29 fedora165 named[5644]: zone 1.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: NS '1.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' has no address records (A or AAAA)
Feb 21 02:23:29 fedora165 named[5644]: zone 1.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: loaded serial 0
Feb 21 02:23:29 fedora165 named[5644]: zone test.co.kr/IN: loaded serial 2009030300
Feb 21 02:23:30 fedora165 named[5644]: zone localhost.localdomain/IN: loaded serial 0
Feb 21 02:23:30 fedora165 named[5644]: zone localhost/IN: loaded serial 0
Feb 21 02:23:30 fedora165 named[5644]: running
[/var/named]#