'dns'에 해당되는 글 1건

  1. 2008.09.02 DNS Server Management
2008. 9. 2. 18:55

DNS Server Management

 

 

 

                DNS Server Management

 

 

 

 

 

[참고] 실무에서 많이 사용되고 있는 서비스

-> DNS, FTP, MAIL, WEB(WAS), DB Server

 

 

 

1. DNS 서버 설정 파일들

 

/etc/named.conf                DNS Configuration File

 

/var/named/exampleXXX.zone     DNS Forward Lookup Zone File

/var/named/exampleXXX.rev      DNS Reverse Loookup Zone File

/var/named/localhost.rev       DNS Localhost Reverse Lookup Zone File

/var/named/named.root          DNS Root Domain Lookup File

 

/etc/nsswitch.conf             Name Service Switching Configuration File

/etc/resolv.conf               DNS Client Resolver File     

 

 

 

(1). /etc/named.conf 파일 해석

 

/etc/named.conf 파일을 in.named 데몬이 읽어 들이는 DNS 서버의 주 설정 파일이다.

 

BIND 8.X 이후 버전에서는 이전의 버전에 비해 새로운 설정 파일을 사용한다.

■ 이전 설정 파일  : /etc/named.boot (BIND 4.x)

■ 새로운 설정 파일: /etc/named.conf (BIND 8.x, BIND 9.x)

 

BIND 4.9.x 버전의 /etc/named.boot 파일을 /etc/named.conf 파일로 변환하기 위해서는

/usr/sbin/named-bootconf 스크립트를 사용하면 된다.

 

/etc/named.conf 파일에서 사용되는 것은 다음과 같다.

- Root Server가 등록되어진 파일 위치 지정

- Primary / Secondary / Caching-Only Server 지정 및 DB 파일 지정

- DNS 서버의 zones of Authority 지정

- 서버용 파일들의 위치 지정

- 도메인에 대한 보안 설정

- 로그 기록 정의 지정

- zone 옵션 지정

 

 

# cat /etc/named.conf

-----------------------------------------------------------------------

options {

    directory "/var/named";

    allow-transfer { 172.16.8.154; 172.16.7.154; };//마스터와 슬레이브와의 관계

    allow-query    { 172.16.8.0/16; };//나에게 쿼리를 날릴 수 있는 대역 지정

};

 

acl "nets" {

    { 172.16.0.0/16; 172.15.0.0/16; };

};

 

zone "." IN {

    type hint;

    file "named.root";

};

 

zone "localhost" IN {

    type master;

    file "localhost.zone";

};

 

zone "0.0.127.in-addr.arpa" IN {

    type master;

    file "localhost.rev";

};

 

zone "example.com" IN {

    type master;

    file "example.zone";

    allow-transfer { 172.16.8.154; };

    allow-query    { "nets"; };

};

 

zone "8.16.172.in-addr.arpa" IN {

    type master;

    file "example.rev";

};

 

zone "daum.net" IN {

    type master;

    file "db1/daum.zone";

};

 

zone "7.16.172.in-addr.arpa" IN {

    type master;

    file "db/daum.rev";

};

zone "daum.net" IN {

    type slave;

masters { 172.16.8.254;};

    file "db1/daum.zone";

};

 

-----------------------------------------------------------------------

 

zone block 에 정의된 것을 순서대로 나열하면 다음과 같다.

- Hint Server(캐쉬 네임서버 지정)

- Reverse Localhost(로컬네트워크 리버스 도메인 지정)

- Forward Primary Name Server(네임서버가 위치하는 곳의 포워드 도메인 지정)

- Reverse Primary Name Server(네임서버가 위치하는 곳의 리버스 도메인 지정)

 

 

 

(1-1). 각 도메인 설정 파일들의 위치 지정

 

-----------------------------------------------------------------------

options {

    directory "/var/named";

};

-----------------------------------------------------------------------

 

각 도메인의 설정파일들이 위치할 디렉토리를 정의한다. 보통 /var/named 디렉토리를 많이

지정한다. 하지만 보안상의 이유로 기본 위치를 지정하지 않고 /named와 같이 다른 디렉토

리를 지정하는 경우도 많다. 이 경우의 대부분은 chroot 환경을 구성하는 경우이다.

 

이 파일의 전반적인 부분에서 "file" 다음에 나오는 모든 파일은 /var/named 디렉토리 하

위에 존재하게 된다. 경우에 따라서 다음과 같이 지정하는 경우도 존재한다.

 

zone "example254.com" IN {

           type master;

           file "zone1/example254.zone";

};

 

위와 같은 경우 포워드 존 파일의 위치는 /var/named/zone1/example254.zone 파일이 된다.

여러개의 도메인을 관리하는 도메인 위임 서버(웹 호스팅 업체)에서는 위와 같은 경우의

선언이 흔하게 된다.

 

 

[참고] options statemnet, directory element

 

     options

           Controls global server configuration options and  sets

           defaults for other statements.

 

     directory

           The working directory of the server.  Any non-absolute

           pathnames  in  the configuration file will be taken as

           relative to this directory.  The default location  for

           most  server  output files, for example, named.run, is

           this  directory.  If a directory is not specified, the

           working  directory defaults to ".", the directory from

           which the server was started.  The directory specified

           should be an absolute path.

 

 

 

(1-2). ACL 설정

 

-----------------------------------------------------------------------

acl "nets" {

    { 172.16.0.0/16; 172.15.0.0/16; };

};

-----------------------------------------------------------------------

 

allow-transfer, allow-query 같은 지시자를 사용해서 설정할때 사용하기 위한 ACL(Access

Control List) 설정할 사용한다.

 

 

[참고] acl statement allow-transfer element

 

     acl   Defines a named IP address matching list,  for  access

           control and other uses.

 

           allow-transfer

                 Specifies which hosts  are  allowed  to  receive

                 zone  transfers from the server.  allow-transfer

                 may also be specified in the zone statement,  in

                 which  case  it  overrides  the  options  allow-

                 transfer  statement.   If  not  specified,   the

                 default is to allow transfers from all hosts.

 

 

 

(1-3). 캐쉬 네임서버와 로컬네트워크 설정

 

-----------------------------------------------------------------------

 

zone "." IN {

    type hint;

    file "named.root";

};

 

zone "0.0.127.in-addr.arpa" IN {

    type master;

    file "localhost.rev";

};

 

-----------------------------------------------------------------------

 

캐쉬 네임 서버와 로컬 네트워크 설정은 반드시 있어야 하는 부분이다. 캐쉬 네임서버는

자신의 DB 정보(Forward Zone File, Reverse Zone File)이 없는 경우에 참고할 Root Name

Server의 위치를 지정하거나 로컬호스트에 대한 지정을 하는 부분이다.

 

[참고] zone statement, hint / master elements

 

     zone  Defines a zone.

 

     hint  The initial set of  root  name  servers  is  specified

           using  a hint zone. When the server starts up, it uses

           the root hints to find a root name server and get  the

           most recent list of root name servers.

 

   master  The server has a master copy of the data for the  zone

           and  will be able to provide authoritative answers for

           it.

 

 

 

(1-4). 포워드 도메인 / 리버스 도메인 파일 설정

 

Forward / Reverse Lookup Zone Files 설정을 한다. 아래 예제는 example.com 도메인에 대

해서 Master DNS 서버로 동작하고 Forward Lookup Zone 파일은 /var/named/example.zone

파일임을 나타낸다. 또한 "nets" 네트워크에 대해서만 Zone 파일들이 전송할수 있도록 한

정이 되어 있다.(Master Server에서 Slave Server로)

 

-----------------------------------------------------------------------

zone "example.com" IN {

    type master;

    file "example.zone";

    allow-transfer { "nets"; };

    allow-query { "nets"; };

};

 

zone "8.168.192.in-addr.arpa" IN {

    type master;

    file "example.rev";

};

-----------------------------------------------------------------------

 

 

 

(2). /var/named/named.root 파일 해석

 

named.root 파일은 ftp.internic.net 이나 rs.internic.net 사이트에서 FTP 접속하여

을 수 있다. 접속하여 파일을 받을수 있는 디렉토리는 /domain 디렉토리에 존재한다.

 

다음은 ftp.internic.net 사이트에서 받은 named.root 파일의 내용이다.

 

# cat /var/named/named.root

-----------------------------------------------------------------------

.                        3600000  IN  NS    A.ROOT-SERVERS.NET.

A.ROOT-SERVERS.NET.      3600000      A     198.41.0.4

.                        3600000      NS    B.ROOT-SERVERS.NET.

B.ROOT-SERVERS.NET.      3600000      A     192.228.79.201

.                        3600000      NS    C.ROOT-SERVERS.NET.

C.ROOT-SERVERS.NET.      3600000      A     192.33.4.12

.                        3600000      NS    D.ROOT-SERVERS.NET.

D.ROOT-SERVERS.NET.      3600000      A     128.8.10.90

.                        3600000      NS    E.ROOT-SERVERS.NET.

E.ROOT-SERVERS.NET.      3600000      A     192.203.230.10

.                        3600000      NS    F.ROOT-SERVERS.NET.

F.ROOT-SERVERS.NET.      3600000      A     192.5.5.241

.                        3600000      NS    G.ROOT-SERVERS.NET.

G.ROOT-SERVERS.NET.      3600000      A     192.112.36.4

.                        3600000      NS    H.ROOT-SERVERS.NET.

H.ROOT-SERVERS.NET.      3600000      A     128.63.2.53

.                        3600000      NS    I.ROOT-SERVERS.NET.

I.ROOT-SERVERS.NET.      3600000      A     192.36.148.17

.                        3600000      NS    J.ROOT-SERVERS.NET.

J.ROOT-SERVERS.NET.      3600000      A     192.58.128.30

.                        3600000      NS    K.ROOT-SERVERS.NET.

K.ROOT-SERVERS.NET.      3600000      A     193.0.14.129

.                        3600000      NS    L.ROOT-SERVERS.NET.

L.ROOT-SERVERS.NET.      3600000      A     198.32.64.12

.                        3600000      NS    M.ROOT-SERVERS.NET.

M.ROOT-SERVERS.NET.      3600000      A     202.12.27.33

-----------------------------------------------------------------------

 

 

하지만 수업을 위해서 변경이 된 파일을 사용할 것이다. 다음은 변경된 파일이다.

 

# cat /var/named/named.root

.                       86400     IN    NS     ns.example.com.

ns.example.com.         86400     IN     A     172.16.8.254

 

 

 

(3). /var/named/exampleXXX.zone 파일 해석

 

Forward-Domain 파일안에는 호스트 이름을 IP에 맵핑시키는 정보가 주로 설정된다. 이 정

보를 설정하기 위해서는 A Record를 사용한다. 이 외에도 SOA, NS, MX, CNAME 등의 Record

를 지정할 수 있다.

 

다음은 /var/named/exampleXXX.zone 파일을 예제이다.

 

# cat /var/named/exampleXXX.zone

-----------------------------------------------------------------------

$TTL 4

$ORIGIN example.com.   //선언이안되어있다면 /etc/named.conf example.com 이 오리지날

@  IN SOA ns.example.com. root.example.com. (

2007051801 ; serial number

3M         ; refresh time

1M         ; retry time

1W         ; expiry day

1D         ; time to live

)

 

example.com.        IN  NS    ns.example.com.

ns.example.com.     IN  A     172.16.8.254

example.com.        IN  NS    ns2.example.com.

ns2.example.com.    IN  A     172.16.8.154

 

;================================================

; Basic Network

;================================================

www                 IN  A     172.16.8.254

www                 IN  A     172.16.8.253

www                 IN  A     172.16.8.252

 

example.com.        IN  MX 10 mail.example.com.

mail                IN  A     172.16.8.254

example.com.        IN  MX 20 mailhost.example.com.

mailhost            IN  A     172.16.8.254

 

ftp                 IN  A     172.16.8.254

 

cname1              IN  A     172.16.8.253

cname2              IN  CNAME cname1

-----------------------------------------------------------------------

 

 

파일을 해석할 때 필요한 정보들에 대해 자세히 알아 보자.

 

(3-1). DNS Zone Files Entry Format

 

(형식)

[Domain]   [TTL]  CLASS  RecordType  Data

 

* [Domain] 부분이 생략되면 오리지널 도메인이 된다. 오리지널 도메인을 찾는 순서는 다

  음과 같다.

  - zone 파일내의 $ORIGIN 값에 지정된 것

  - /etc/named.conf 파일의 포워드 존의 도메인

 

* [TTL] 부분이 생략된면 $TTL 에 의해 지정된 값이 된다. TTL(Time To Live)가 지정되는

  순서는 다음과 같다.

  - 각 엔트리의 TTL 값에 지정된 것

  - $TTL로 지정된 값

  - SOA 지시자의 TTL 필드의 값

 

* CLASS는 현재 다른 것이 없고 IN(Internet)만 존재한다.

* RecoredType에 따라서 첫번째 필드와 마지막 필드가 결정된다.

 

[EX] 다양한 RecordType의 예

example.com.       IN SOA   ns.example.com. root.example.com (Number .....)

                     SOA domain

example.com.       IN NS    ns.example.com.

                     NS - nameserver

ns.example.com.    IN A     172.16.8.254

                     A - address

www.example.com.   IN A     172.16.8.254   

example.com.       IN MX 10 mail.example.com.

172.16.8.254       IN PTR   ns.example.com.

 

[EX] RecordType TEST

# nslookup -q=NS example.com

# nslookup -q=A ns.example.com

# nslookup -q=MX example.com

# nslookup -q=PTR 172.16.8.254

 

 

(3-2). 주석처리(Comment)

- ;       (Window 주석처리)

- #       (Unix 주석처리)

- /* */   (C 주석처리)

- //      (C++ 주석처리)

 

 

 

(3-3). SOA(Start Of Authority) Record

 

(예) SOA Record Type

@  IN SOA ns.example.com. root.example.com. (

2007051801 ; serial number

3H         ; refresh time

1H         ; retry time

1W         ; expiry day

1D         ; time to live

)

 

====== Master ========           ======= Slave ==========

in.named(53)                       in.named(53)

/etc/named.conf                    /etc/named.conf

/var/named/DB                      /var/named/copy DB

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

 

(a). Serial Number

 

    exampleXXX.zone      ---->       exampleXXX.zone

      Serial : 1                        Serial : 1

      Modify

      Serial : 2           >            Serial : ?

      (권장) Serial : 2006122000

 

(b). Refresh Time                     // 동기화타임

    Mater Server        ----->       Slave Server

                       3 hours

      (권장) 12시간, 24시간

 

(c). Retry Time                              // 재시도 타임

    Master Server       --X-->       Slave Server

                       3 hours       Fail

                        ----->

                       1 hours

      (권장) 1시간, 3시간

 

(d). Expire Date                      // 마스터가 죽었을 때 대체 복구 시간

    Master Server                    Slave Server

                        ------>

      Fail              ---X-->

                                      Data(7 Days)

      (권장) 7

 

(e). TTL(Time To Live)

    Server              ------>      Client

      (권장) 1

 

 

 

(3-4). 여러가지 레코드 종류(Record Types)

 

(a). NS Record (Name Server)

example.com.     IN   NS   ns.example.com.

domain                    full domain (nameserver)

ns.example.com.  IN   A    172.16.8.254

nameserver                    ip

 

(b). A Record (Address)

www.example.com. IN   A   172.16.8.254

 

(c). MX Record (Mail Exchange)

example.com.     IN   MX  10  mail1.example.com.

domain                        full domain

mail1            IN   A       172.16.8.254

name                          ip

example.com.     IN   MX  20  mail2.example.com.

mail2            IN   A       172.16.10.254

 

[참고] SPAM 메일서버, 일반 메일 서버 등록 방식

 

(d). CNAME Record (Canonical Name)

www1             IN   A       172.16.8.254

www2             IN   A       172.16.8.254

or

www1             IN   A       172.16.8.254

www2             IN  CNAME    www1

 

(e). PTR Record (Pointer)

254              IN   PTR      www.example.com.

 

 

 

(4) /var/named/exampleXXX.rev 파일 해석

 

Reverse Domain 파일은 주로 IP 주소에 Domain Name 맵핑된 정보가 주로 설정된다.

정을 하기 위해서는 PTR Record를 사용한다. Reverse Domain 파일안에 반드시 등록 되어 있

어야 하는 정의는 자신의 도메인안에 존재하는 DNS 서버에 대한 Reverse Domain이다.

 

# cat /var/named/exampleXXX.rev

-----------------------------------------------------------------------

$TTL 4

$ORIGIN 8.16.172.IN-ADDR.ARPA.

@ 1D IN SOA ns.example.com. root.example.com. (

2007051800 ; serial number

3M         ; refresh time

1M         ; retry time

1W         ; expiry day

1D         ; minimum time

)

 

8.16.172.IN-ADDR.ARPA.  IN  NS    ns.example.com.

254                     IN  PTR   ns.example.com.

-----------------------------------------------------------------------

 

[참고] 리버스 존 파일안에 반드시 정의 되어야 하는 설정

DNS Client                 DNS Server

          --------------->

          <---------------

          --------------->

          <---------------

 

# nslookup www.itbank.co.kr

.....

59.5.100.166 -> 168.126.63.1 DNS C 1.63.126.168.in-addr.arpa. Internet PTR ?

168.126.63.1 -> 59.5.100.166 DNS R 1.63.126.168.in-addr.arpa. Internet PTR kns.kornet.net.

59.5.100.166 -> 168.126.63.1 DNS C www.itbank.co.kr. Internet Addr ?

168.126.63.1 -> 59.5.100.166 DNS R www.itbank.co.kr. Internet Addr 58.185.71.171

.....

 

 

 

(4-1). PTR Record

 

PTR Record Type(Pointer)

254              IN   PTR      www.example.com.

 

[EX] Recored Type 필드

8.16.172.IN-ADDR.ARPA.  IN  NS    ns.example.com.

254                     IN  PTR   ns.example.com.

200                     IN  PTR   solaris200.example.com.

201                     IN  PTR   solaris201.example.com.

202                     IN  PTR   solaris202.example.com.

 

 

[EX] PTR / A Record Type 실습

 

ftp.example.com -> 172.16.8.200

 

# vi /var/named/example254.zone

.....

ftp                     IN  A     172.16.8.200

.....

# vi /var/named/example254.rev

.....

200                     IN  PTR   ftp.example.com.

.....

 

 

 

(5) /var/named/localhost.rev 해석

 

Reverse Loopback Domain 파일은 Reverse Loopback Domain 주소에 대해 Domain Name으로

변환하는 역할을 갖는다. 모든 도메인 서버는 자신의 주소를 master DNS Server 설정이

되어야 한다.

 

형식은 위의 파일과 같다. 해석하는 방법은 같다.

 

# cat /var/named/localhost.rev

-----------------------------------------------------------------------

$TTL 4

@ 1D IN SOA ns.example.com. root.example.com. (

2007051800 ; serial number

3M         ; refresh time

1M         ; retry time

1W         ; expiry day

1D         ; minimum time

)

 

0.0.127.IN-ADDR.ARPA. IN  NS    ns.example.com.

1                     IN  PTR   ns.example.com.

-----------------------------------------------------------------------

 

 

(6). /etc/nsswitch.conf 파일 해석

 

/etc/nsswitch.conf 파일은 이름서비스를 제공하는 서버들의 정보를 얻어 올수 있는 순서

를 정하는 중요한 파일이다.

 

# cat /etc/nsswitch.conf

......

# You must also set up the /etc/resolv.conf file for DNS name

# server lookup.  See resolv.conf(4).

hosts:      files dns

......

 

 

 

(7) /etc/resolv.conf 파일 해석

 

# cat /etc/resolv.conf

domain example.com

search example.com

nameserver 172.16.8.XXX

nameserver 172.16.8.254

 

/etc/resolve.conf 파일안에 정의 될수있는 statements

 

* domain      - 자신의 lcoal domain을 적어 주면된다. domain이 설정되지 않아도 운영

                하는데 아무런 지장이 없다.

                (예) domain example.com

 

* search      - search에 의해 지정된 되메인 부분은 생략할 수 있도록 하는 것이다. 만

                약 "search example.com"로 지정되어 있다면 example.com의 서브 도메인

                들은 그냥 호스트이름만으로도 찾을 수 있게 된다.

                예를 들어 www.example.com를 찾을려고 한다면 www 만으로도 사용이 가능

                하다.

                (예) search example.com

                (사용예) # ping www

                         # nslookup www

 

* nameserver  - DNS 서버를 지칭한다. 일반적으로 3개까지 지정할수 있으면 그 이상 정의

                된것은 인식이 되지 않는다. 회사내에서는 1차 DNS 서버와 2차 DNS 서버

                를 정의하면 된다.

                (예)     nameserver 168.126.63.1

                                      nameserver 168.126.63.2

                                      nameserver 168.126.63.3

 

 

[EX] /etc/resolv.conf 해석 순서 확인

 

# cat /etc/resolv.conf

nameserver 172.16.8.XXX

 

 

http://www.daum.net -> /etc/hosts -> DNS(172.16.8.XXX) -> .(Nameless Root)

 

 

# nslookup www.daum.net      

Server:  ns.solarisXXX.example.com

Address:  172.16.8.XXX

 

*** ns.solarisXXX.example.com can't find www.daum.net: Server failed  <----- 에러 메세지 확인

 

# vi /etc/resolv.conf

nameserver 168.126.63.1   <----- 정보 라인 추가

nameserver 172.16.8.XXX

 

# nslookup www.daum.net

Server:  kns.kornet.net

Address:  168.126.63.1

 

Non-authoritative answer:

Name:    daumtop.daum.akadns.net

Addresses:  211.115.77.213, 211.115.77.212, 211.115.115.212, 211.32.117.30

          211.115.115.211, 222.231.51.78, 211.115.77.214, 222.231.51.40

Aliases:  www.daum.net

 

# vi /etc/resolv.conf

nameserver 172.16.8.XXX   <----+---- 정의 순서 교체

nameserver 168.126.63.1   <----+

 

# pkill -9 in.named

# pgrep -lf in.named

(in.named 데몬 종료 여부 확인)

 

# nslookup www.daum.net

( 15초정도의 Time Interval 걸린다.)

*** Can't find server name for address 172.16.8.20X: No response from server

Server:  kns.kornet.net

Address:  168.126.63.1

 

Non-authoritative answer:

Name:    daumtop.daum.akadns.net

Addresses:  211.115.115.212, 211.32.117.30, 222.231.51.77, 211.115.77.213

          211.115.77.214, 211.115.77.211, 222.231.51.78, 222.231.51.40

Aliases:  www.daum.net

 

# in.named

# nslookup www.daum.net

-> 정보 요청이 되지 않는다.

 

 

 

 

 

 

               DNS Server Administrator Role

 

 

 

 

DNS Server Admin. Role List

도메인 등록 (Domain Insert)

서브 도메인 위임(Sub Domain Configuration = Domain Delegation)

마스터 / 슬레이브 DNS 서버 (Master Server, Slave Server)

캐싱 / 포워딩 DNS 서버 (Caching Olny Server, Forwarding Server)

DNS 부하 분산 (DNS Load Balancing = Web Load Balancing )

동적 업데이트 설정(Dynamic Updates)

보안 설정 (Security / ACL(Access Control List))

 

 

 

(1). 도메인 등록(Domain Insert)

 

DNS 서버 관리자에게 다음과 같은 도메인에 대한 IP 설정 요청이 들어 왔다고 해보자.

 

도메인에 IP 주소 등록 요청 예

- 172.16.8.254   ===>   www.solaris254.example.com

- 172.16.8.254   ===>   mail.solaris254.example.com

- 172.16.8.254   ===>   ftp.solaris254.example.com

 

Forward Domain 파일에 등록

Forward Zone File (example254.zone)

 

# vi /var/named/example254.zone

.....

www          IN   A      172.16.8.254

             IN   MX 10  mail

mail         IN   A      172.16.8.254

ftp          IN   A      172.16.8.254

.....

 

# vi /var/named/example254.rev

254          IN   PTR     www.solaris254.example.com.

254          IN   PTR     ftp.solaris254.example.com.  (X)

254          IN   PTR     mail.solaris254.example.com. (X)

//중복 정보 x

 

(EX1) 도메인 등록

 

■ 도메인에 IP 주소 등록 요청 예

- 172.16.8.XXX   ===>   cafe.solarisXXX.example.com

 

# cd /var/named

# vi exampleXXX.zone

......

;================================

; Domain Configuration for Test

;================================

[수정전]

test         IN   A   172.16.8.XXX

[수정후]

test         IN   A   172.16.8.XXX

cafe         IN   A   172.16.8.XXX    <----- 라인 추가

......

 

# pkill -1 in.named

# nslookup cafe.solarisXXX.example.com

(출력 정보 확인)

 

 

 

 

 

Client -------> DNS(192.168.10.XXX)

(Windows XP)   /var/named/exampleXXX.zone

                www     IN  A  192.168.10.XXX

       -----------------------------------------> Apache(192.168.10.XXX)

                                                  httpd(80, httpd.conf)

http://www.solarisXXX.example.com

 

 

■ Apache 설정

(주 설정 파일 설정)

# cd /etc/apache

# cp httpd.conf-example httpd.conf

 

(index.html 파일 생성)

# cd /var/apache/htdocs

# cp /etc/passwd index.html

 

(Apache 서버 기동)

# /etc/init.d/apache restart

# pgrep -lf httpd

-> 떠 있는 httpd 데몬들 확인

 

(DNS 설정 변경)

# cd /var/named

# vi exampleXXX.zone

[수정전]

;www          IN   A       172.16.8.XXX

www           IN   A       192.168.10.1

www           IN   A       192.168.10.2

www           IN   A       192.168.10.3

[수정후]

www           IN   A       192.168.10.XXX    <----- 라인 추가

;www          IN   A       172.16.8.XXX     

;www          IN   A       192.168.10.1      <----- 주석 처리

;www          IN   A       192.168.10.2      <----- 주석 처리

;www          IN   A       192.168.10.3      <----- 주석 처리

 

# pkill -1 in.named

# nslookup www.solarisXXX.example.com

 

(Window Server에서 확인)

네트워크 환경 > 로컬영역 연결 > 속성 > TCP/IP > DNS 서버 정보(192.168.10.XXX)

 

웹브라우저 에서 확인

http://www.solarisXXX.example.com

 

=> DNS 서버 정보 복원(Windows 서버)

 

 

 

(EX2) 부하분산(Load Balancing)

 

웹 부하 분산을 시킬때 DNS 서버를 사용할 수도 있다. 하지만 이것은 정확한 부하 분산이

라고 말할수는 없다. 이런경우 L4 스위치를 사용하는 경우와는 조금의 차이점이 존재한다.

 

         예: www.daum.net

        +----- www(IP1)      +---- NAS

        |                    |

[L4]----+----- www(IP2) -----+---- DB

        |

        +----- www(IP3)

 

     [그림] L4 스위치를 사용한 웹 부하 분산의 예

 

 

        +----- www(IP1)      +---- NAS

        |                    |

[DNS]---+----- www(IP2) -----+---- DB

        |

        +----- www(IP3)

 

     [그림] DNS 서버를 이용한 웹 부하 분산의 예

 

[참고] NAS?

/root/docs/Reference/DAS_NAS_SAN.txt

 

 

[EX] Windows 서버에서의 테스트

C:\> nslookup www.daum.net

Server:  kns.kornet.net

Address:  168.126.63.1

 

Non-authoritative answer:

Name:    daumtop.daum.akadns.net

Addresses:  211.115.77.213, 211.115.77.211, 211.32.117.30, 211.115.115.212

          211.115.77.214, 222.231.51.78, 222.231.51.77, 211.115.115.211

Aliases:  www.daum.net

 

 

C:\> nslookup www.daum.net

Server:  kns.kornet.net

Address:  168.126.63.1

 

Non-authoritative answer:

Name:    daumtop.daum.akadns.net

Addresses:  211.115.77.211, 211.115.115.212, 222.231.51.77, 211.115.115.211

          211.32.117.30, 211.115.77.213, 211.115.77.212, 222.231.51.40

Aliases:  www.daum.net

 

 

C:\> nslookup www.daum.net

Server:  kns.kornet.net

Address:  168.126.63.1

 

Non-authoritative answer:

Name:    daumtop.daum.akadns.net

Addresses:  211.115.77.213, 211.115.77.211, 211.32.117.30, 211.115.115.212

          211.115.77.214, 222.231.51.78, 222.231.51.77, 211.115.115.211

Aliases:  www.daum.net

 

 

C:\> nslookup www.daum.net

Server:  kns.kornet.net

Address:  168.126.63.1

 

Non-authoritative answer:

Name:    daumtop.daum.akadns.net

Addresses:  211.115.77.212, 222.231.51.40, 211.115.77.211, 222.231.51.78

          211.115.77.214, 211.32.117.30, 211.115.77.213, 211.115.115.212

Aliases:  www.daum.net

 

 

Forward Zone File (exampleXXX.zone)

# vi /var/named/exampleXXX.zone

.....

[수정전]

www           IN   A       192.168.10.XXX

;www          IN   A       172.16.8.XXX     

;www          IN   A       192.168.10.1 

;www          IN   A       192.168.10.2 

;www          IN   A       192.168.10.3 

[수정후]

;www          IN   A       192.168.10.XXX     <----- 주석 처리

;www          IN   A       172.16.8.XXX 

www           IN   A       192.168.10.1       <----- 주석 제거

www           IN   A       192.168.10.2       <----- 주석 제거

www           IN   A       192.168.10.3       <----- 주석 제거

.....

 

# pkill -1 in.named

# nslookup www.solarisXXX.example.com

(정보 확인 1초후에 다시 시도)

# nslookup www.solarisXXX.example.com

(정보 확인 및 1초후에 다시 시도)

# nslookup www.solarisXXX.example.com

(정보 확인 및 1초후에 다시 시도)

# nslookup www.solarisXXX.example.com

(정보 확인 및 1초후에 다시 시도)

 

 

 

(2). 도메인 위임(Domain Delegation)

 

도메인 위임은 일반적으로 웹호스팅 업체(예:가비아)에서 일반적으로 많이 사용하고 있다.

 

[참고] domain 할당 받는 방법(예: 가비아)

 

+---------------------- example.com ------------------------+

|* DNS(ns.example.com)                                      |

|                                                           |

|   +----- solarisXXX.example.com ------+                   |

|   | * DNS(ns.solarisXXX.example.com)  |                   |

|   |                                   |                   |

|   |                                   |                   |

|   +-----------------------------------+                   |

|                                                           |

+-----------------------------------------------------------+

 

DNS(ns.example.com)

# vi /var/named/example254.zone

.....

solaris200.example.com.       IN  NS  ns.solaris200.example.com.

ns.solaris200.example.com.    IN  A   172.16.8.200

.....

or

solaris200                    IN  NS  ns.solaris200

ns.solaris200                 IN  A   172.16.8.200

.....

 

# vi /var/named/example254.rev

.....

200                           IN  PTR  ns.solaris200.example.com.

 

 

[EX] Hint Domain Administration

+----------------- . (Nameless Root Domain)-----------------+

|* DNS(A.ROOT-SERVERS.NET)                                  |

|                                                           |

|   +----------- .com ------------------+                   |

|   | * DNS(ns.com)                     |                   |

|   |                                   |                   |

|   |                                   |                   |

|   +-----------------------------------+                   |

|                                                           |

+-----------------------------------------------------------+

 

# vi /var/named/example254.zone

....

com.                          IN  NS  ns.com.

ns.com.                       IN  A   172.16.8.200

....

 

 

 

(3). 마스터 / 슬레이브 DNS 서버 구성

 

Master Server / Slave Server

 

====== Master Server =======    ======== Slave Server ========

    in.named(53)                    in.named(53)

    /etc/named.conf                 /etc/named.conf

      - Forward Zone File(M)           - Forward Zone File(S)

      - Reverse Zone File(M)           - Reverse Zone File(S)

      - Localhost Zone File(M)         - Localhost Zone File(M)

      - Zone File for Hint             - Zone File for Hint

    /var/named/Zone File            /var/named/Copy Zone File

      - Forward Zone File              - Copy Forward Zone File

      - Reverse Zone File              - Copy Reverse Zone File

      - Localhost Zone File            - Localhost Zone File

      - Zone File for Hint             - Zone File for Hint

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

 

             [그림] Master/Slave DNS Server

 

 

(전제 조건)

- Master DNS 서버의 도메인을 따른다.

        solaris201(Master DNS Server) - solaris201.example.com => solaris201.example.com

        solaris202(Slave DNS Server)  - solaris202.example.com => solaris201.example.com

- 자리 배치에 따른 서버 결정

        왼: Master, 오: Slave, 앞: Master, 뒤: Slave

 

(자리 배치도)

--------------------------------------------------------

                solarisXXX(172.16.8.XXX)

--------------------------------------------------------

200 201 202            203 204 205

 

206 207 208            209 210 211

 

212 213 214            215 216 217

 

218 219 220            221 222 223

 

224 225 226            227 228 229

--------------------------------------------------------

 

 

 

(3-1). Master DNS Server 서버쪽 설정

 

# vi /var/named/example254.zone

......

example.com.     IN   NS   ns1.example.com.

example.com.     IN   NS   ns2.example.com.

ns1              IN   A    172.16.8.254

ns2              IN   A    172.16.8.253

......

 

# vi /var/named/example254.rev

......

                 IN   NS   ns1.example.com.

                 IN   NS   ns2.example.com.

254              IN   PTR  ns1.example.com.

253              IN   PTR  ns2.example.com.

......

 

 

 

(3-2). Slave DNS Server 서버쪽 설정

 

# vi /etc/named.conf

......

     zone "example.com" in {

          type slave;

          file "example254.zone";

          masters { 172.16.8.254; };    <----- 172.16.8.254: Master DNS IP

     };

 

     zone "8.16.172.in-addr.arpa" in {

          type slave;

          file "example254.rev";

          masters { 172.16.8.254; };    <----- 172.16.8.254: Master DNS IP

     };

......

 

# cd /var/named

# ls

localhost.rev  named.root

 

 

 

[실습] DNS Master / Slave Server Configuration

 

(실습시나리오)

Domain : solaris201.example.com(Master DNS Server 도메인)

DNS1   : ns.solaris201.example.com  (solaris201)

            ^^^^^^^^^^^^^^^^^^^^^^

DNS2   : ns2.solaris201.example.com (solaris202)

             ^^^^^^^^^^^^^^^^^^^^^^

 

+---------------------- example.com ------------------------+

|* DNS(ns.example.com)                                      |

|                                                           |

|   +----- solarisXXX.example.com ------+                   |

|   | * DNS-ns.solarisXXX.example.com   |                   |

|   | *    -ns2.solarisXXX.example.com  |                   |

|   |                                   |                   |

|   +-----------------------------------+                   |

|                                                           |

+-----------------------------------------------------------+

 

 

(At Master DNS Server)

- Forward Zone File 편집

- Reverse Zone File 편집

 

(a). Forward Zone File 편집

# vi /var/named/example201.zone

.....

;

; DNS Server(Primary)

;

solaris201.example.com.  IN   NS      ns.solaris201.example.com.

solaris201.example.com.  IN   NS      ns2.solaris201.example.com.  <----- 라인 추가

ns                       IN   A       172.16.8.201

ns2                      IN   A       172.16.8.202                 <----- 라인 추가

.....

 

(b). Reverse Zone File 편집

# vi /var/named/example201.rev

......

8.16.172.IN-ADDR.ARPA. IN   NS      ns.solaris201.example.com.

8.16.172.IN-ADDR.ARPA. IN   NS      ns2.solaris201.example.com.    <----- 라인 추가

201                    IN   PTR     ns.solaris201.example.com.

202                    IN   PTR     ns2.solaris201.example.com.    <----- 라인 추가

......

 

# pkill -1 in.named

# tail -f /var/adm/messages

 

 

 

(At Slave DNS Server)

- /etc/named.conf 설정

- /var/named 파일 정리

 

(a). /etc/named.conf 파일 편집

# vi /etc/named.conf

.....

zone "solaris201.example.com" in {       <----- 정보 수정(solaris202 -> solaris201)

         type slave;                     <----- 정보 수정(master -> slave)

         masters { 172.16.8.201; };      <----- 라인 추가

         file "example201_backup.zone";  <----- 정보 수정

                                         (example202.zone -> example201_backup.zone)

};

 

zone "8.16.172.in-addr.arpa" in {

         type slave;                     <----- 정보 수정(master -> slave)

         masters { 172.16.8.201; };      <----- 라인 추가

         file "example201_backup.rev";   <----- 정보 수정

                                         (example202.rev -> example201_backup.rev)

};

.....

 

(b). /var/named 파일 정리

# cd /var/named

# rm example202.zone example202.rev

 

# tail -f /var/adm/messages

# pkill -1 in.named

# cd /var/named

# ls

(새로 생성된 Zone File 확인)

 

 

 

[Check Point] Slave Server

-> /var/named/(Zone File) 생성 확인

-> /var/adm/messages 로그 기록 정보 확인

 

 

 

(Master / Slave Zone Data Update 설정 테스트)

(At Master DNS Server)

# cd /var/named

# vi example201.zone

......

;--------------------------------

; Configuration for Test Domain

;--------------------------------

[수정전]

test          IN   A       172.16.8.201

cafe          IN   A       172.16.8.254

[수정후]

test          IN   A       172.16.8.201

cafe          IN   A       172.16.8.254

test1         IN   A       172.16.8.254     <----- 라인 추가

......

 

# pkill -1 in.named

# nslookup test1.solaris201.example.com

-> 출력 화면 확인

 

 

(At Slave DNS Server)

# cd /var/named

# grep test example201_backup.zone

test    4       IN      A       172.16.8.201

 

# pkill -1 in.named

# grep test example201_backup.zone

test    4       IN      A       172.16.8.201

 

 

(At Master DNS Server)

# vi example201.zone

......

20060930    ; serial number  (serial number 값을 높였다.)

......

;

; Configuration for Test Domain

;

[수정전]

test          IN   A       172.16.8.201

cafe          IN   A       172.16.8.254

test1         IN   A       172.16.8.254

[수정후]

test          IN   A       172.16.8.201

cafe          IN   A       172.16.8.254

test1         IN   A       172.16.8.254

test2         IN   A       172.16.8.254      <----- 라인 추가

......

# pkill -1 in.named

 

 

(At Slave DNS Server)

# pkill -1 in.named

 

# grep test example201_backup.zone

test    4       IN      A       172.16.8.201

test1   4       IN      A       172.16.8.254

test2   4       IN      A       172.16.8.254

 

 

 

(4). Caching-Only DNS Server / Forwarding DNS Server 구성

 

(4-1). Caching Only Server 설정

 

====== Caching Only Server ======= 

    in.named(53)                  

    /etc/named.conf              

      - Localhost Zone File(M)

      - Zone File for Hint  

    /var/named/Zone File   

      - Localhost Zone File

      - Zone File for Hint

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

 

[그림] Caching Only DNS Server

 

 

 

(4-2). Forwarding DNS Server 구성

 

====== Forwarding Server =======    ======== DNS Server ========

    in.named(53)                    in.named(53)

    /etc/named.conf                 /etc/named.conf

                                                   - Forward Zone File

                                       - Reverse Zone File

                                       - Localhost Zone File

                                       - Zone File for Hint

                                    /var/named

                                                   - Forward Zone File

                                       - Reverse Zone File

                                       - Localhost Zone File

                                       - Zone File for Hint

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

 

              [그림] Forwarding DNS Server

 

 

Forwarding Server 설정

 

# vi /etc/named.conf

.....

options {

        directory "/var/named";

        forwarders { 172.16.10.254; };

        forward only;

};

.....

 

 

 

(5). Dynamic Updates 기능 설정

 

DNS 서버에서 동적 업데이트(Dynamic Updates) 기능은 DHCP 서버로 부터 호스트에 대한

정보를 동적으로 업데이트하는 기능이다. 이 기능을 통해 DHCP 서버로 부터 동적으로 할

당받은 클라이언트들이 관리자의 특별한 설정 없이도 서버 시스템에 접근하거나 서비스를

받을수 있다. Dynamic Update 기능을 설정하기 위해서는 DNS Master Server의 설정을 다음

과 같이 해야 한다.

 

Dynamic Update 는 해당 도메인의 Authority 를 갖는 네임서버를 통해  Zone 파일을 수정

치 않고도 레코드를 동적으로 원격 갱신할 수 있도록 한다. 도메인 관리를 자동화 하거나,

사용자 별로 접속 도메인을 실시간 변경하여 제공하거나, DHCP에서의 주소-IP 매칭등과

같이 실시간적으로 레코드가 변경, 갱신 될 필요가 있는 서비스에 특히 유용할 수 있다.

 

Dynamic Update 는 BIND 8 부터 지원이 되며 BIND 9 에서의 변화는 dnssec-key 를 이용한

인증부분의 강화되었다.

 

 

■ Master DNS 서버 설정

 

# vi /etc/named.conf

 

     zone "example.com" in {

          type master;

          file "example254.zone";

          allow-update { 127.0.0.1; 172.16.8.254; };

     };

     zone "8.16.172.in-addr.arpa" in {

          type master;

          file "example254.rev";

          allow-update { 127.0.0.1; 172.16.8.254; };

     };

 

# pkill -1 in.named

 

 

 

(6). DNS 보안 설정

 

DNS 서버의 설정은 인증되지 않은 클라이언트에게도 정보가 노출될수 있다. BIND 8.X 버전

부터 /etc/named.conf 파일에 allow-query, allow-transfer 키워드를 통해 보안 설정을 할

수 있다.

 

allow-query 키워드는 DNS 쿼리를 요청할 수 있는 지역을 IP에 기반해서 설정 할 수 있다.

일반적으로 DNS Server와 DNS Client의 관계를 보안적으로 구성할 수 있다. 일반적으로 회

사내에 존재하는 DNS 서버에 DNS 서버에 쿼리를 요청할 수 있는 클라이언트 대역을 회사내

로 한정하여 설정하는 것을 권장한다.

 

allow-transfer 키워드는 DNS 존 파일을 전송받을수 있는 지역을 선택할수 있다.

DNS Master Server와 DNS Slave Server의 관계를 보안적으로 구성할 수 있다. 일반적으로

회사내에 존재하는 DNS Master Server에서 allow-transfer를 통해 존 파일을 전송할 수 있

는 DNS Slave Server의 IP를 지정할 것을 권장한다.

 

■ Security / ACL(Access Control List)

- 데이터 암호화(Data Encryption)

- chroot 환경 설정

- 프로그램 업데이트, 프로그램 패치

- Master => Slave(Zone 파일들이 전달될수 있는 영역 지정)

- Server => Client(Zone File에 대한 Query 영역 지정)

 

(At Master DNS System)

# vi /etc/named.conf

.....

options {

    allow-query { 172.16.0.0/16; 172.17.0.0/16; 192.168.8.0/24 };

    .....

};

.....

zone "example.com" in {

        type master;

        file "exmaple254.zone;

        allow-transfer { 172.16.8.253; 192.168.8.252; };

        allow-query { 172.16.0.0/16; 172.15.0.0/16; };

}

.....

 

 

 

(7). ndc 명령어

 

ndc 명령어를 사용하여 DNS Server의 설정을 변경할 수 있고 in.named 데몬을 제어 할 수

있다. 기본의 방식은 in.named 데몬에 대해 SIGHUP, SIGIINT 등과 같은 시그널을 사용해서

제어 했지만 ndc 명령어를 사용하면 좀 더 세세한 정보와 제어가 가능하다. ndc 명령어는

대화형 모드와 비 대화형 모드의 실행이 가능하다. BIND 9.X 버전에서는 rndc 명령어로 변

경이 되었다.

 

# ndc

Type   help  -or-   /h   if you need help.

ndc> /h

        /h(elp)                 this text

        /e(xit)                 leave this program

        /t(race)                toggle tracing (protocol and system events)

        /d(ebug)                toggle debugging (internal program events)

        /q(uiet)                toggle quietude (prompts and results)

        /s(ilent)               toggle silence (suppresses nonfatal errors)

 

ndc> help

(builtin) start - start the server

(builtin) restart - stop server if any, start a new one

getpid

status

stop

exec

reload [zone] ...

reconfig [-noexpired] (just sees new/gone zones)

dumpdb

stats [clear]

trace [level]

notrace

querylog

qrylog

help

quit

args

 

ndc> restart

new pid is 1197

/e                           <----- '/e' 입력

 

# ndc

ndc> status

in.named BIND 8.3.3 Thu Jun 16 08:11:42 PDT 2005  Generic Patch-5.9-June 2005

config (/etc/named.conf) last loaded at age: Thu Oct 18 00:11:35 2007

number of zones allocated: 64

debug level: 0

xfers running: 0

xfers deferred: 0

soa queries in progress: 0

query logging is OFF

server is initialising itself

 

ndc> dumpdb

Database dump initiated.

 

ndc> /e                           <----- '/e' 입력

 

# cd /var/named

# ls -l named_dump.db

-rw-r--r--   1 root     root        2.5K Oct 18 01:45 named_dump.db

 

 

[참고] ndc 명령어 사용을 다른 예

 

ndc> /t

tracing now on

 

ndc> restart

ndc: [command 'exec']

ndc: [220 BIND 8.3.3]

ndc: [250 Restart initiated.]

ndc: [command 'getpid']

ndc: [220 BIND 8.3.3]

ndc: [250 my pid is <1210>]

pid 1210 is running

new pid is 1210

/e                           <----- '/e' 입력

 

 

# ndc

ndc> /t        //trace mode

tracing now on

 

ndc> /d        //usr1 signal

debugging now on

 

ndc> restart

ndc: [command 'exec']

ndc: [isc/ctl_clnt::new_state: initializing -> connecting]

ndc: [isc/ctl_clnt::new_state: connecting -> connected]

ndc: [isc/ctl_clnt::readable: read 16, used 16]

ndc: [220 BIND 8.3.3]

ndc: [isc/ctl_clnt::readable: read 24, used 24]

ndc: [250 Restart initiated.]

ndc: [isc/ctl_clnt::new_state: connected -> destroyed]

ndc: [command 'getpid']

ndc: [isc/ctl_clnt::new_state: initializing -> connecting]

ndc: [isc/ctl_clnt::new_state: connecting -> connected]

ndc: [isc/ctl_clnt::readable: read 16, used 16]

ndc: [220 BIND 8.3.3]

ndc: [isc/ctl_clnt::readable: read 22, used 22]

ndc: [250 my pid is <1217>]

ndc: [isc/ctl_clnt::new_state: connected -> destroyed]

pid 1217 is running

new pid is 1217

/e                           <----- '/e' 입력

 

 

 

[참고] ndc 명령어(Non-Interractive Mode) 실행

# ndc getpid      in.named 데몬의 PID 번호 보여주기

# ndc status      in.named 상태 보기

# ndc reload      /etc/named.conf & Zone 파일 다시 읽기

# ndc stats       통계 남기기

# ndc querylog    /var/adm/messages 파일에 로그 남기기