DNS 서버구축




BIND 설치


   1.  /usr/local/src 디렉토리로 이동후 wget 사용해서 bind 다운받기

[root@server114 ~]# cd /usr/local/src

[root@server114 src]#

[root@server114 src]#

[root@server114 src]# pwd

/usr/local/src

[root@server114 src]# wget ftp://ftp.isc.org/isc/bind9/9.10.1-P1/bind-9.10.1-P1.tar.gz

--20:19:42--  ftp://ftp.isc.org/isc/bind9/9.10.1-P1/bind-9.10.1-P1.tar.gz

           => `bind-9.10.1-P1.tar.gz'

Resolving ftp.isc.org... 204.152.184.110, 2001:4f8:0:2::18

Connecting to ftp.isc.org|204.152.184.110|:21... connected.

Logging in as anonymous ... Logged in!

==> SYST ... done.    ==> PWD ... done.

==> TYPE I ... done.  ==> CWD /isc/bind9/9.10.1-P1 ... done.

==> SIZE bind-9.10.1-P1.tar.gz ... 8356463

==> PASV ... done.    ==> RETR bind-9.10.1-P1.tar.gz ... done.

Length: 8356463 (8.0M)

100%[=======================================>] 8,356,463    803K/s   in 15s

20:19:59 (551 KB/s) - `bind-9.10.1-P1.tar.gz' saved [8356463]



  2. 압축해체하고 해당 디렉토리로 이동후, 경로옵션 지정후 시스템에 적당한 환경파일 생성하기

[root@server114 src]# tar zxf bind-9.10.1-P1.tar.gz

[root@server114 src]# ls

bind-9.10.1-P1  bind-9.10.1-P1.tar.gz

[root@server114 src]#

[root@server114 src]# cd bind-9.10.1-P1


[root@server114 bind-9.10.1-P1]# ./configure  --prefix=/usr/local/dns     (/usr/local/dns 디렉토리 생성한뒤)




​  3. make로 컴파일후, 프로그램설치

[root@server114 bind-9.10.1-P1]# make

......(컴파일목록)

[root@server114 bind-9.10.1-P1]# make install

.......(설치목록)







파일 환경설정 named.conf


 1. /usr/local/dns/etc 로 이동 후 vi로 named.conf 파일 생성

[root@server114 bind-9.10.1-P1]# cd /usr/local/dns/etc

[root@server114 etc]# ls

bind.keys

[root@server114 etc]# vi named.conf


? ​/usr/local/dns 디렉토리 생성 안하고 configure 했더니 /usr/local/dns/etc 에 bind.key 파일이 존재하지 않았음. 

 그래서디렉토리 생성후 다시 configure함. (bind-9.10.1-P1에서 configure.) 그럼, 전에 make install했던 나의 bind.key는 어디로 간거야? 읭??????


 2. named.conf 환경설정하기


/*

directory : 네임서버에서 데이터베이스 역활을 하는 존(zone)파일의 위치를 설정
dump-file :   named는 정보가 갱신될 때 dump파일로 저장하는데 그 덤프파일이 생성될 위치아 파일명을 지정
statistics-file : 네임서버의 통계를 낼 경우에 사용하는 옵션으로 메모리 통계 파일을 생성할 위치와 파일명 지정
allow-transfer : zone 파일의 내용을 복사할 대상에 제한을 걸 때 지정
*/




options {
        directory "/var/named";
        dump-file "/var/tmp/named_dmp.db";
        statistics-file "/var/tmp/named.stats";
        pid-file "/var/run/named.pid";
        allow-transfer { 172.16.5.114; };        
};
logging {
        category lame-servers { null; };
        category notify { null; };
};


zone "localhost" IN {
        type master;
        file "zone-localhost";
}; 

zone "naver.com" IN {
        type master;
        file "zone-naver.com";
};




​ 

파일 환경설정 zone file


1. /var/named 디렉토리 생성후 이동해서 zone file 작성

[root@server114 var]# mkdir /var/named

[root@server114 var]# cd /var/named

[root@server114 named]#

[root@server114 named]# vi zone-localhost


2zone-localhost 환경설정하기

[root@server114 named]# vi zone-localhost


$TTL 86400

@       IN      SOA     @       root (

        42              ; serial (d. adams)

        3H              ; refresh

        15M            ; retry

        1W             ; expiry

        1D )            ; minimum


        IN      NS      @

        IN      A       172.16.5.114

 


3. zone-naver.com 환경설정하기

[root@server114 named]# vi zone-naver.com


$TTL 86400

@       IN      SOA     @       root (

        42              ; serial (d. adams)

        3H              ; refresh

        15M            ; retry

        1W             ; expiry

        1D )            ; minimum


        IN      NS      @

  


        IN      A       173.194.127.152              

www   IN      A       173.194.127.152                  -> 순서 바뀌면 존파일 확인오류뜸.

 


4. zone file 확인하기. (/usr/local/dns/sbin 으로 이동한 뒤)

[root@server114 named]# cd /usr/local/dns/sbin

[root@server114 sbin]# ./named-checkzone naver.com /var/named/zone-naver.com

zone naver.com/IN: loaded serial 42

OK

[root@server114 sbin]# ./named-checkzone localhost /var/named/zone-localhost

zone localhost/IN: loaded serial 42

OK

 

[root@server114 sbin]#

 


5. 설정확인 및 테스트

[root@server114 sbin]# ./named

[root@server114 sbin]# ps -ef | grep -v grep | grep named

root     16297     1  0 23:25 ?        00:00:00 ./named




 DNS 서버 변경후 네트워크 재시작


 1. /etc/resolv.conf 열어서 변경하고 네트워크재시작 후 dns 서버변경 확인


[root@server114 sbin]# vi /etc/resolv.conf                                    ; dns서버를 내 아이피주소로 설정함.

[root@server114 sbin]# service network restart

Shutting down interface eth0:                              [  OK  ]

Shutting down loopback interface:                          [  OK  ]

Bringing up loopback interface:                            [  OK  ]

Bringing up interface eth0:                                [  OK  ]





2. nslookup으로 변경 확인

[root@server114 named]# nslookup

> naver.com

Server:         172.16.5.114

Address:        172.16.5.114#53


Name:   naver.com

Address: 173.194.127.152      -> 구글 ip주소.

>


>> VMware상 RHEL5 인터넷켜서 naver.com치면 google열림


'linux' 카테고리의 다른 글

[서버구축] Mail  (30) 2016.03.08
[서버구축] FTP  (73) 2016.03.08
Shell Script  (163) 2016.03.08
Visual Editor(vi editor) 명령어 / network 정보  (153) 2016.03.08
[명령어] - 3. Process / RPM / Cron 관리  (160) 2016.03.08