본문 바로가기
운영체제/리눅스

[CentOS] Named 서버 설정하기

by o테리o 2011. 7. 22.

1. 프로그램 설치

  -> yum -y install bind*
  -> yum -y install caching-name*


2. named 파일 생성 (기존에 파일없슴, 메뉴얼에 생성해주라함)
  -> cp /usr/share/doc/bind-9.3.4/sample/etc/* /var/named/chroot/etc/
  -> cp /usr/share/doc/bind-9.3.4/sample/var/named/* /var/named/chroot/var/named/


3. named.conf 편집
  -> vim  /var/named/chroot/etc/named.conf
options
{
   directory "/var/named"; // the default
   dump-file   "data/cache_dump.db";
   statistics-file  "data/named_stats.txt";
   memstatistics-file  "data/named_mem_stats.txt";
};
logging
{
        channel default_debug {
                file "data/named.run";
                severity dynamic;
         };
        category lame-servers { null; };
};

view "localhost_resolver"
{
    match-clients   { localhost; };
    match-destinations { localhost; };
    recursion yes;
    include "/etc/named.root.hints";
    include "/etc/named.rfc1912.zones";
};
view "internal"
{
    match-clients  { localnets; };
    match-destinations { localnets; };
    recursion yes;
    include "/etc/named.root.hints";

    zone "example.co.kr" {
                   type master;
                   file "data/example.co.kr.zone";
    };
};

//key ddns_key
//{
//      algorithm hmac-md5;
//      secret "use /usr/sbin/dns-keygen to generate TSIG keys";
//};

view    "external"
{
    match-clients  { any; };
    recursion no;
    include "/etc/named.root.hints";
    zone "example.co.kr" {
                type master;
                file "data/example.co.kr.zone";
    };
};

4. vi /var/named/chroot/etc/named.rfc1912.zones 편집

//추가
zone "example.co.kr" IN {
        type master;
        file "data/example.co.kr.zone";
        allow-update { none; };
}; 

도메인 역순으로 예를 들어 116.123.89.197 이면 4번째 197을 제외한 89.123.116 순으로 작성
zone "3.2.1.in-addr.arpa" IN {  

        type master;
        file "data/3.2.1.rev";    //1.2.3.4 => 3.2.1.rev
        allow-update { none; };
};

5. vim /var/named/chroot/var/named/data/3.2.1.rev

$TTL    86400
@       IN      SOA     example.co.kr. root.example.co.kr.  (
                                      1997022700 ; Serial
                                      28800      ; Refresh
                                      14400      ; Retry
                                      3600000    ; Expire
                                      86400 )    ; Minimum
       IN      NS      ns.example.co.kr.
4     IN      PTR     ns.example.co.kr.
4     IN      PTR     www.example.com.

6. name 서버 본문 파일 편집
  -> vim /var/named/chroot/var/named/data/example.co.kr.zone
$TTL    86400
@               IN SOA  @       root (                     ( root 앞에 @ 빼먹지 말자)
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum
                IN NS           ns1.example.co.kr. (맨끝에 .을 빼먹지 말자)
                IN NS           ns2.example.co.kr.
                IN mx 10      mail
@              IN A            123.123.1.90      ( @ 중요합니다. @없으면 DNS request error 남)
ns1           IN A            123.123.1.90
ns2           IN A            123.123.1.90
www         IN A            123.123.1.90
ftp             IN A            123.123.1.90     (abc.example.co.kr 의 abc 호스트 네임 추가해주는 부분)
mail                  IN A            123.123.1.90
phpmyadmin      IN A     123.123.1.90

7. 심볼릭 링크 (/etc/named.conf 심볼릭링크)
  -> cd /etc
  -> ln -s /var/named/chroot/etc/named.conf .

8. 서비스 추가
  -> ntsysv // named 서비스 추가

9. 네트워크 DNS 설정
  -> vi /etc/resolv.conf
  -> nameserver 192.168.0.90   //현 서버의 내부IP나 공인IP로 변경

10. #/sbin/service network restart

11. #/sbin/service named start

// DNS 서버 확인
 dig example.co.kr
 nslookup example.co.kr
 nslookup 1.2.3.4    //자신의 공인아이피로 도메인이 나오는지 확인

// error가 있을시 tail -100 /var/log/message 로 로그확인


붉은색 글씨부분만 변경하고자 하는 도메인으로 변경하심됨


출처: http://831218.com/49