CentOs 네임서버세팅

Posted by Albert 4872Day 21Hour 7Min 49Sec ago [2011-12-17]

file nameserver.docx

수정할파일 모두 6개. 실행시킬 대상 3개

우선 /etc/hosts 파일을 열어서 연결될 도메인을 설정한다.

[root@localhost named]' vi /etc/hosts

======================================================================

127.0.0.1                   albert.com      albert

192.168.116.135         www.albert.com  www.albert

======================================================================

위처럼 자신의 도메인추가후 resolv.conf  파일에서 네임서버를 설정하여 준다
[root@localhost named]' vi /etc/resolv.conf 

======================================================================

domain albert.com
search albert.com
nameserver 192.168.116.2
nameserver 192.168.116.135
nameserver 168.126.63.1
======================================================================

네임서버 세팅에서 반드시 caching-nameserver 가 설치되어야한다.

우선 서버에 이미깔려있는지 확인한다.

[root@localhost named]' rpm -qa | grep cach*    

libXfontcache-1.0.2-3.1
distcache-1.4.5-14.1

없으면 os설치파일 혹은 패키지를 다운받아 설치해준다.

[root@localhost CentOS]' rpm -ivh caching-nameserver-9.3.6-16.P1.el5.i386.rpm

설치완료후 named로 시작되는 2개 파일을 확인할수있다.

[root@localhost CentOS]' cd /var/named/chroot/etc/
[root@localhost etc]' ll
합계 32
-rw-r--r-- 1 root root   380 11월 12 19:09 localtime
-rw-r----- 1 root named 1195 11월 16 14:12 named.caching-nameserver.conf
-rw-r----- 1 root named 1193 11월 16 14:14 named.rfc1912.zones
-rw-r----- 1 root named  113 11월 12 18:50 rndc.key

우선 named.caching-nameserver.conf 를 세팅한다.

[root@localhost etc]' vi named.caching-nameserver.conf

=======================================================================================================
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; };
        allow-query-cache { any; };
};
logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};
view localhost_resolver {
        match-clients      { any; };
        match-destinations { any; };
        recursion no;
        include "/etc/named.rfc1912.zones";
};
=======================================================================================================
수정후 named.rfc1912.zones 파일도 수정한다.

참고로 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 { 라인 기준으로

윗2개항목을 복사하여 제일마지막에 부쳐넣고 자신의 환경에 맞게 설정한다.

[root@localhost etc]' vi named.rfc1912.zones
=======================================================================================================

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; };
};

zone "albert.com" IN {
        type master;
        file "albert.com.zone";
        allow-update { none; };
};

zone "116.168.192.in-addr.arpa" IN {
        type master;
        file "albert.com.rev";
        allow-update { none; };
};
====================================================================================

이렇게 설정후 /var/named/chroot/var/named/ 폴더로 이동한다

이동후 named.local 파일을 복사하여 자신의 도메인에 맞는 zone파일 생성한다.

생성후 해당 파일을 열고 편집한다.

[root@localhost etc]' cd /var/named/chroot/var/named/

cp named.local albert.com.zone
[root@localhost named]' cp named.local albert.com.zone

[root@localhost named]' vi albert.com.zone

===========================================================================================

$TTL    86400

@       IN      SOA     www.albert.com. root.www.albert.com.  (

                                      2011121700 ; Serial

                                      28800      ; Refresh

                                      14400      ; Retry

                                      3600000    ; Expire

                                      86400 )    ; Minimum

        IN      NS      www.albert.com.

        IN      A       192.168.116.135

www     IN      A       192.168.116.135

===========================================================================================

다음 rev파일도 복사해서 생성한다.
[root@localhost named]' vi albert.com.rev

===========================================================================================

$TTL    86400

@       IN      SOA     www.albert.com. root.www.albert.com.  (

                                      2011121700 ; Serial

                                      28800      ; Refresh

                                      14400      ; Retry

                                      3600000    ; Expire

                                      86400 )    ; Minimum

        IN      NS      www.albert.com.

        IN      A       192.168.116.135

135     IN      PTR     www.albert.com.

===========================================================================================

이렇게 세팅하면 전부의 도메인 및 네임서버세팅은 끝난다.

자 그럼 네임서버가 잘 되었는지 확인해보기로 하자

[root@localhost named]' /etc/rc.d/init.d/httpd restart
httpd 를 정지 중:                                          [실패]
httpd (을)를 시작 중:                                      [  OK  ]
[root@localhost named]' /etc/rc
rc          rc.local    rc.sysinit  rc1.d/      rc3.d/      rc5.d/
rc.d/       rc.news     rc0.d/      rc2.d/      rc4.d/      rc6.d/
[root@localhost named]' /etc/rc.d/init.d/named restart
named를 정지 중:                                           [  OK  ]
named를 시작 중:                                           [  OK  ]
[root@localhost named]' ping albert.com
PING albert.com (192.168.116.135) 56(84) bytes of data.
64 bytes from albert.com (192.168.116.135): icmp_seq=1 ttl=64 time=4.00 ms

아파치 및 네임서버 모두 정상적으로 잘 재부팅되는것을 확인할수있다. 그리고 ping도 잘나간다.

그리고 

[root@localhost /]' nslookup

> server www.albert.com

Default server: www.albert.com

Address: 192.168.116.135'53

> www.albert.com

Server:         www.albert.com

Address:        192.168.116.135'53


Name:   www.albert.com

Address: 192.168.116.135


nslookup 실행하여 최종적으로 다시 확인한다.
가끔 외부에서 접속않될때가 있는데 그럴땐 방화벽에서 53포트가 차단되었는지 확인할 필요가있다.
그리고 /var/named/chroot/var/named/  에만든 zone 파일과rev파일의 소요권이 named로 되어있는지도 확인할 필요가있다

^^

 




LIST

Copyright © 2014 visionboy.me All Right Reserved.