*** master DNS 설정

[root@star named]# cat /etc/named.conf
//
// named.conf for Red Hat caching-nameserver
//

options {
directory "/var/named";
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 "localdomain.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 "lee.pe.kr" IN {
type master;
file "lee.zone";
allow-update { none; };
allow-transfer { 192.168.20.200; };
};


zone "20.168.192.in-addr.arpa" IN {
type master;
file "192.168.20.rzone";
# allow-update { 192.168.20.200; };

allow-transfer { 192.168.20.200; };
};

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

[root@star named]# cat lee.zone
$TTL 86400
@ IN SOA lee.pe.kr. root.lee.pe.kr. (
20080728 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS ns.lee.pe.kr.
IN NS ns2.lee.pe.kr.

ns IN A 192.168.20.101
ns2 IN A 192.168.20.200
www IN A 192.168.20.102
@ IN A 192.168.20.102
[root@star named]#

[root@star named]# cat 192.168.20.rzone
$TTL 86400
@ IN SOA lee.pe.kr. root.lee.pe.kr. (
20080728 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS ns.lee.pe.kr.
IN NS ns2.lee.pe.kr.

101 IN PTR ns.lee.pe.kr.
102 IN PTR www.lee.pe.kr.
200 IN PTR ns2.lee.pe.kr.
[root@star named]#

[root@star named]# cat /etc/resolv.conf
;nameserver 168.126.63.1
nameserver 192.168.20.101

[root@star named]# /etc/init.d/named start
named (을)를 시작합니다: [ 확인 ]

[root@star named]# pgrep -fl named
24828 /usr/sbin/named -u named -t /var/named/chroot

*. 보안을 위해서 과거버전과 달리 /var/named 가 아닌 /var/named/chroot 에서 설정파일을 찾는다.
*. chroot 기능을 사용하지 않으려면 /usr/sbin/named -u named 로 실행하면 된다.

[root@star named]# cat /etc/resolv.conf => 직접구성한 dns 서버를 현재 호스트에서 직접 테스트 하려면
;nameserver 168.126.63.1
nameserver 192.168.20.101 => 이것을 직접구성한 dns ip 로 바꾸어야 한다.
[root@star named]#

그리고 아래결과처럼 dns 서버의 ip 는 설정되어 있어야 하고 활성화 되어 있어야 한다.
그래야 클라이언트의 요청에 dns 서버가 응답할 수 있다.

[root@star named]# ifconfig eth0:1
eth0:1 Link encap:Ethernet HWaddr 00:0C:29:9E:9E:DF
inet addr:192.168.20.101 Bcast:192.168.20.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:10 Base address:0x2000

[root@star named]#

그리고 ping 으로 응답하는지 확인해본다.

[root@star named]# ping 192.168.20.101
PING 192.168.20.101 (192.168.20.101) 56(84) bytes of data.
64 bytes from 192.168.20.101: icmp_seq=0 ttl=64 time=1.44 ms
64 bytes from 192.168.20.101: icmp_seq=1 ttl=64 time=0.008 ms

--- 192.168.20.101 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 0.008/0.727/1.446/0.719 ms, pipe 2
[root@star named]#

=> 정상적으로 응답하고 있음을 알수 있다.

[root@star named]# nslookup <= dns 에 등록된 도메인을 확인하는 명령어이다.
> www.lee.pe.kr
Server: 192.168.20.101
Address: 192.168.20.101#53

Name: www.lee.pe.kr
Address: 192.168.20.102
> 192.168.20.101
Server: 192.168.20.101
Address: 192.168.20.101#53

101.20.168.192.in-addr.arpa name = ns.lee.pe.kr.
> www.yahoo.co.kr
Server: 192.168.20.101
Address: 192.168.20.101#53

Non-authoritative answer:
www.yahoo.co.kr canonical name = yahoo.co.kr.
Name: yahoo.co.kr
Address: 119.161.11.206
Name: yahoo.co.kr
Address: 203.212.171.217
> lee.pe.kr
Server: 192.168.20.101
Address: 192.168.20.101#53

Name: lee.pe.kr
Address: 192.168.20.102
> exit

[root@star named]#

*. dns 서버가 제대로 동작 하지 않는다면 로그 파일을 보고 어디에 문제가 있는지를 찾아내서 고쳐야 한다.
*. dns 의 로그기록은 /var/log/messages 파일에 저장되어 있다.

[root@star named]# tail -10 /var/log/messages
Aug 16 02:23:04 star named[24828]: zone localhost/IN: loaded serial 42
Aug 16 02:23:04 star named[24828]: running
Aug 16 02:23:04 star named[24828]: zone lee.pe.kr/IN: sending notifies (serial 20080728)
Aug 16 02:23:04 star named[24828]: zone 20.168.192.in-addr.arpa/IN: sending notifies (serial 20080728)
Aug 16 02:23:04 star named[24828]: client 192.168.20.101#32769: received notify for zone 'lee.pe.kr'
Aug 16 02:23:05 star named[24828]: client 192.168.20.101#32769: received notify for zone '20.168.192.in-addr.arpa'
Aug 16 02:38:02 star crond(pam_unix)[24990]: session opened for user root by (uid=0)
Aug 16 02:38:02 star crond(pam_unix)[24990]: session closed for user root
Aug 16 02:39:02 star crond(pam_unix)[25002]: session opened for user root by (uid=0)
Aug 16 02:39:02 star crond(pam_unix)[25002]: session closed for user root
[root@star named]#


######################################################
설정 예. (centos 5.x)

named.caching-nameserver.conf 파일을 테스트를 위해 아래처럼 수정합니다.
이 파일이 없으면 yum install caching-nameserver 명령어로 설치부터해야합니다.

1 //
2 // named.caching-nameserver.conf
3 //
4 // Provided by Red Hat caching-nameserver package to configure the
5 // ISC BIND named(8) DNS server as a caching only nameserver
6 // (as a localhost DNS resolver only).
7 //
8 // See /usr/share/doc/bind*/sample/ for example named configuration files.
9 //
10 // DO NOT EDIT THIS FILE - use system-config-bind or an editor
11 // to create named.conf - edits to this file will be lost on
12 // caching-nameserver package upgrade.
13 //
14 options {
15 // listen-on port 53 { 127.0.0.1; };
16 listen-on port 53 { any; };
17 // listen-on-v6 port 53 { ::1; };
18 directory "/var/named";
19 dump-file "/var/named/data/cache_dump.db";
20 statistics-file "/var/named/data/named_stats.txt";
21 memstatistics-file "/var/named/data/named_mem_stats.txt";
22
23 // Those options should be used carefully because they disable port
24 // randomization
25 query-source port 53;
26 // query-source-v6 port 53;
27
28 // allow-query { localhost; };
29 allow-query { any; };
30 allow-notify { any; };
31 };
32 logging {
33 channel default_debug {
34 file "data/named.run";
35 severity dynamic;
36 };
37 };
38 view localhost_resolver {
39 // match-clients { localhost; };
40 match-clients { any; };
41 // match-destinations { localhost; };
42 match-destinations { any; };
43 recursion yes;
44 include "/etc/named.rfc1912.zones";
45 };

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

/etc/named.rfc19212.zones 파일 맨 아래에 아래와
같이 도메인을 하나 추가합니다.

zone "lee.pe.kr" IN {
type master;
file "lee.hosts";
};

zone "100.168.192.in-addr.arpa" IN {
type master;
file "192.168.100.rev";
};

================================
/etc/var/named/chroot/var/named 디렉토리에
lee.hosts 파일을 아래와 같이 작성합니다.
*. 설정할때 주의할점 - 도메인명으로 끝날때는 끝에 root 도메인을 의미하는
마침표를 꼭 붙여줘야 합니다. 그렇지 않으면 제대로 동작하지 않습니다.

1 $TTL 86400
2 @ IN SOA ns.myunix.co.kr. root.myunix.co.kr. (
3 2009072401 ; Serial
4 60 ; Refresh
5 14400 ; Retry
6 600 ; Expire
7 86400 ) ; Minimum
8 IN NS ns.myunix.co.kr.
9 ns IN A 192.168.100.1
10 www IN A 192.168.100.2
11 ftp IN A 192.168.100.3

===================================
/etc/var/named/chroot/var/named 디렉토리에
192.168.100.rev 파일을 아래와 같이 작성합니다.

[root@centos1 named]# cat 192.168.100.rev

1 $TTL 86400
2 @ IN SOA ns.myunix.co.kr. root.myunix.co.kr. (
3 201006133 ; Serial
4 60 ; Refresh
5 14400 ; Retry
6 600 ; Expire
7 86400 ) ; Minimum
8 IN NS ns.myunix.co.kr.
9 1 IN PTR ns.myunix.co.kr.
10 2 IN PTR www.myunix.co.kr.
11 3 IN PTR ftp.myunix.co.kr.

================================================
그리고 작성한 파일퍼미션은 named 가 읽을수 있게 권한 설정을 고쳐주어야합니다.

chgrp named lee.hosts
chgrp named 192.168.100.rev

/etc/resolv.conf 파일은 자신이 테스트할 dns서버를 적어둡니다.
[root@centos1 named]# cat /etc/resolv.conf
nameserver 192.168.100.1

그리고 dns ip 를 하나 할당합니다.
ifconfig eth0:1(또는 eth1:1) 192.168.100.1
그런다음 service named start

여기서 에러가 발생하였다면 /var/log/messages 파일을 보고 에러를 잡아야 합니다.
그리고 dns 설정파일을 수정한 경우에는 설정을 적용하기 위해서 dns 서비슬
재시작 해야 합니다.

nslookup 명령으로 테스트 했을때 문제가 없다면
도메인을 추가로 하나를 더 등록해서 테스트하면 dns 를 이해하는데 더 도움이 될것입니다.

'Log > Linux' 카테고리의 다른 글

dns 설정 실습  (0) 2011.11.28
DNS - Secondary(Slave) 구성  (0) 2011.11.28
dns 설정파일 문법  (0) 2011.11.28
DNS - Domain Name Service  (0) 2011.11.28
압축유틸리티/백업복구/패키지관리  (0) 2011.11.28
Posted by logwatch

2011. 11. 28. 19:29 Log/Linux

dns 설정파일 문법

*. 아래는 dns 설정파일의 기본적인 문법

/etc/named.conf

// comment
/*
comment
*/

기본형식 :
keword {
설정내용 ;

};

ex)
options {
directory path_name;
기타 부가적인 설정...;
}

zone 구문

zone "." IN {
type hint;
file 파일명;
};

zone "domain name" IN {
type master ; => slave dns 일경우 type 은 slave 가 되어야 한다.
file file명;
}

zone "10.168.192.in-addr.arpa" IN {
type master;
file file명;
};

*. 세부설정 파일 문법
1. forward 설정파일

$TTL value
@ IN SOA dns도메인명. 이메일주소. (
serial_number ; serial => 여기서 ';' 은 주석을 의미한다. dns 가 설정이 처음 하는 사람에게
refresh_number; refresh 쉽지않은 부분은 이런 주석까지도 named.conf 에서 사용하는
retry_number; retry 것과 이파일에서 사용하는것이 같지 않은점. 그리고 '.' 을
expire_number; expire 하나 누락해도 동작을 제대로 하지 않는점 이런것들
minmum_number; minimun 때문일것이다.
);

IN NS dns도메인명(호스트명 포함(FQDN)).
hostname IN ip-address
hostname IN ip-address
...
*. hostname 대신에 (FQDN을 사용해도 된다. ex) www.abc.co.kr.
주의할점은 FQDN(host명을포함한 도메인)을 적을때는 맨끝에 '.' 을
반드시 붙여야 한다. 그렇지 않으면 host명으로 간주한다.

$TTL value ; 다른 dns 가 root dns 를 통해서 여기에 있는 정보를 참조했을때
이 정보를 캐시에 담아두는 기간.
ex) $TTL 86400(= $TTL 24h) => 다른 dns 가 여기 있는 정보를 참조하면
여기있는 정보를 24시간동안 캐시에 담아두겠다는 의미.
단위가 없으면 초를 의미하고 h 는 시간 d는 day m은 분, w는 주 이렇게 여거가지
단위를 붙여 표현할수 있다. $TTL 24h = $TTL 1d 와 같은 의미.

serial_number : slave dns 가 primary dns zone 설정을 업데이트 하기 위한
값으로 사용된다. slave dns 는 자신이 가지고 있는 zone 파일과 이파일을 비교하여
primary dns 에 있는 serial number 가 더 높은 경우에만 업데이트한다.
serial_number 는 기간을 의미 하지 않는다. 보통 날짜 형태의 표기를 한다.
ex) 2009100700

refresh number ; slave dns 가 primary dns 의 설정파일을 업데이트 하는 주기
retry number ; slave dns 가 refresh time 에 도달하여 update 를 하려고 했으나
primary dns 로 부터 응답이 없는경우 재시도 하는시간.
expire number ; slave dns 가 primary dns 와 어떤 문제로 통신이 되지 않게되면
slave dns 가 가지고 있는 정보는 신뢰성이 떨어지게 된다.
그걸경우 데이터를 파기하는 시간이다.
minimum number ; $TTL 과 다소 차이가 있지만 같은 의미로 봐도 된다.
그리고 해당되는 각 설정값은 관리자가 임의로 설정할 수 있다.
$TTL value <= 맨 첫번째 줄에 이부분이 와야 한다.
이거 없어도 동작하지만 경고메시지가 출력될것이다.
@ IN SOA dns도메인명. 이메일주소. ( <= 두번째 줄은 이부분이 반드시 와야 한다. 문법이 그렇다.

@ => 그 도메인 자체를 의미 ex) abc.co.kr.

IN ; class 이름인데 특별한 의미는 없으며 모든 레코드 앞에 붙인다.

SOA (Start Of Authority) - 권한의 시작을 의미하는 레코드타입
(그냥 반드시 적어야 할 문법으로 생각하면 됨)

dns도메인명 : name server 도메인명을 호스트 이름을 포함하여 적는다.
이메일주소: 설정하는 도메인에 대해서 책임있는 관리자의 이메일 주소를 적는다.
이때 이메일 주소에는 '@' 문자를 포함하면 안된다.
만약 이메일주소가 root@abc.co.kr 이라면 root.abc.co.kr. 이렇게 표기해야 한다.

IN NS dns도메인명(호스트명 포함(FQDN)). ; NS 는 dns를 의미하는 레코드타입.
- 주의 : IN 앞에 반드시 탭키 또는 스페이스 문자가 있어야 한다. 그렇지 않으면 IN 을 호스트명으로
간주하게 된다.

hostname IN A ip-address

- 주의 : hostname 앞에 스페이스 문자가 있으면 안된다. hostname 은 첫칸부터
시작해야 한다.
A (Address 의 약자)는 도메인 -> ip 로 변환하기 위한 레코드 타입.

2. reverse 설정파일

forward 설정파일과 형식이 거의 같은데 다른 부분은 IN NS 부분 다음줄부터이다.

hostname IN ip-address
hostname IN ip-address

==> forward 설정파일의 이부분만 다르다.
ip-address 의 맨 마지막 자리 IN PTR 도메인명.
ex)
1 IN PTR (Pointer 의 약자) www.abc.co.kr.
2 IN PTR 192.168.10.2 ftp.abc.co.kr.

그리고 named.ca 파일은 root dns 를 찾기 위한 파일이며 이파일은 수정하는것이
아니다. 이 파일이 손상 또는 없는 경우라면 국제인터넷 기구 Internic 에서 다운로드
받아야 한다.

다운로드 주소 : ftp.rs.inetetnic.net 익명계정으로 접속하여 다운 받으면 된다.
이름이 named.root 로 올라와 있을수도 있는데 그런경우에는 다운로드 받은후
이름을 named.ca 로 바꾸면 된다.

여기까지는 아주 기본적인 dns 문법이다.
여기까지의 문법과 기본개념을 잘 이해하면 나머지 좀 더 세부적인 부분을 이해하는데는
별로 어렵지 않다.

*. 참고 : CentOS5 인경우의 BIND 설정파일

'Log > Linux' 카테고리의 다른 글

DNS - Secondary(Slave) 구성  (0) 2011.11.28
DNS - Primary DNS 설정 및 테스트  (0) 2011.11.28
DNS - Domain Name Service  (0) 2011.11.28
압축유틸리티/백업복구/패키지관리  (0) 2011.11.28
ftp 서비스 - server  (0) 2011.11.28
Posted by logwatch

2011. 11. 28. 19:28 Log/Linux

DNS - Domain Name Service

dns 서비스

dns 서버는 크게 세가지가 있다.

1. Primary DNS (또는 Master DNS)

2. Secondary DNS (또는 Slave DNS) - 백업 역할을 하는 DNS.
반드시 필요한 것은 아니며 primary dns 가 다운되었을때 대신 서비스 하기 위한것이다.

3. Cache Only DNS


DNS 역할

다른 호스트에 접속시 ip 주소가 반드시 필요하다.
그러나 ip 주소는 기억하기 어려우므로 보통 도메인 이름을 사용한다.
그래서 필요한 것이 DNS 이다.

도메인에 대한 해당 ip 주소를 알려주는것이 DNS 의 주된 역할이다.


도메인이 ip 주소로 변환되는 과정.

1. 클라이언트: http://www.abc.co.kr
2. ip 주소가 아니므로 클라이언트는 ip주소를 알아내기 위해 /etc/host.conf 파일 참조
여기에 order hosts,bind 로 설정되어 있으면 /etc/hosts 에서 해당도메인 정보를 찾고
없으면 그 다음 /etc/resolv.conf 파일을 참조한다. 적혀있는 순서대로 참조한다.
3. /etc/hosts 파일에 없다고 가정하면 /etc/resolv.conf 를 참조하게 되고
거기에 nameserver 168.126.63.1 이 적혀 있으면 그 주소의 서버에게 도메인 주소를
알려 달라고 요청한다.
4. 168.126.63.1 의 dns 서버가 자신이 가지고 있는 dns zone 설정 파일을 참조해서
해당되는 정보가 있으면 ip 를 알려준다.
5. 클라이언트는 ip 를 알게되었으므로 그 ip 를 가지고 서버에 접속한다.


*. 그런데 4번 단계에서 168.126.63.1(kornet) dns 가 www.abc.co.kr 에 대한 설정을 가지고 있지
않으면 조금 복잡해진다.

이런경우 코넷 dns는 최상위 계층에 존재하는 root dns 에게 www.abc.co.kr 에 대한 도메인 주소를
물어본다. 실제 등록된 domain 주소에 대한 ip 주소는 root dns 는 전부 찾을 수 있다.

5. root dns 는 www.abc.co.kr 에 대한 정보를 찾기 위해서 하위 몇단계를 거쳐 찾는다.
그리고 그 정보를 코넷 dns 한테 알려준다.

6. 코넷 dns는 www.abc.co.kr 주소를 캐시영역에 저장해두고 찾은 ip 주소는 클라이언트에게 알려준다.

*. 그 다음 또 어떤 클라이언트가 코넷 dns에게 www.abc.co.kr 의 ip 를 알려달라고 요청하면
이번에는 캐시에 그 정보가 저장되어 있으므로 root dns 에게 묻지 않고 바로 알려준다.

유닉스에서 주로 사용되는 dns 패키지는 bind 이다.

[root@star etc]# rpm -qa | grep bind
bind-utils-9.3.1-4
bind-9.3.1-4
ypbind-1.17.2-5 => 이건 bind 패키지가 아니다.
bind-chroot-9.3.1-4
bind-libs-9.3.1-4

설치되어 있지 않으면 rpm 또는 yum 으로 설치한다.

*. DNS 설정파일

/etc/named.conf

나머지 세부 설정파일은 /etc/named.conf 의 설정에 따라 경로 및 파일이름이 결정된다.

[root@star etc]# cat /etc/named.conf
// <== // 이 기호는 주석으로 사용된다. 한라인 주석.
// named.conf for Red Hat caching-nameserver
//

options {
directory "/var/named";
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 "localdomain.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; };
};

/* 여기서 부터는 ipV6 를 위한 설정으로 ipV6 사용하지 않는다면
수정할 필요없이 그대로 두면 된다. (/* ~ */ 이 사이에 있는것은 다 주석으로 처리된다)

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

*. named.conf 파일안에 들어가는 설정은 크게 4가지이다.

첫번째 - 세부 설정파일을 저장할 디렉토리 : option
두번째 - root domain zone
세번째 - Forward zone : 도메인 -> ip 변환
네번째 - Reverse zone : ip -> 도메인 변환

[root@star etc]#

'Log > Linux' 카테고리의 다른 글

DNS - Primary DNS 설정 및 테스트  (0) 2011.11.28
dns 설정파일 문법  (0) 2011.11.28
압축유틸리티/백업복구/패키지관리  (0) 2011.11.28
ftp 서비스 - server  (0) 2011.11.28
ftp 서비스 - client  (0) 2011.11.28
Posted by logwatch

블로그 이미지
내가 나에게 확인 하는 블로그
logwatch

태그목록

공지사항

Yesterday
Today
Total

달력

 « |  » 2025.4
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30

최근에 올라온 글

최근에 달린 댓글

글 보관함