Nameserver Howto
DNS 작동원리[편집]
- 우리가 흔히 웹브라우저에서 인터넷에서 검색할때 www.naver.com으로 검색하지, 125.209.222.142로 들어가지는 않잖아요?
- 사실 컴퓨터는 125.209.222.142라는 주소가 있어야 통신을 할 수 있는데, 우리는 www.naver.com만 가지고 들어갑니다.
- 웹브라우저에 www.naver.com을 치면 지정한(고정IP일 경우 설정을 하게 되어 있고, DHCP를 사용할 경우 자동으로 받아오게 되어 있습니다) DNS서버로 naver.com을 보내서 www.naver.com의 IP를 가지고 있는 녀석을 물어봅니다.
- 그럼 naver.com의 네임서버에 서브도메인을 물어봅니다. 결국 네이버 내의 네임서버가 최종적으로 실제 www.naver.com의 IP를 알려줍니다.
- 브라우저 내부적으로는 www.naver.com의 주소를 가지고 통신을 시작합니다. 한 서버에 여러개의 도메인을 가지는 경우 리퍼러를 이용하게 됩니다.
- 다음은 우분투 리눅스 Bind9 버전에서 DNS서버를 Master/Slave로 구축하는 방법입니다.
- 구축하기 앞서서 방화벽을 사용하신다면 TCP/UDP 53번을 열어 주셔야 합니다.
Bind 설치[편집]
bind를 설치 합니다.
{{#ifeq: msg|user|~|{{#ifeq: misc|user|~ sudo apt-get install bind9|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}} sudo apt-get install bind9}}}}
아래 내용을 수정하기 위해서는 루트로 들어가서 작업하는것이 편합니다.
{{#ifeq: msg|user|~|{{#ifeq: misc|user|~ sudo -i|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}} sudo -i}}}}
rndc 생성[편집]
- 생성된 key의 이름을 named.conf 설정 파일에 추가할때 적절한 이름으로 변경합니다.
<source lang="bash">
- rndc-confgen
- vi /etc/bind9/named.conf
# Start of rndc.conf key "rndc-key" { algorithm hmac-md5; secret "yHH6sSaUxOo8m8Fd0t+uyQ=="; };
options {
default-key "rndc-key"; default-server 127.0.0.1; default-port 953;
}; # End of rndc.conf # Use with the following in named.conf, adjusting the allow list as needed: # key "rndc-key" { # algorithm hmac-md5; # secret "yHH6sSaUxOo8m8Fd0t+uyQ=="; # }; # # controls { # inet 127.0.0.1 port 953 # allow { 127.0.0.1; } keys { "rndc-key"; }; # }; # End of named.conf </source>
Master 서버 설정[편집]
<source lang="bash">
- vi /etc/bind/named.conf
options { // zone file이 위치할 곳을 지정합니다. directory "/etc/bind/db"; // NXDOMAIN으로 응답 여부 (기본값 no) auth-nxdomain no; // IPv6 listen-on-v6 { any; }; // BIND 버전을 강제로 지정합니다. version "Yongbok.net"; // 자체 네임서버를 사용할 경우 허용할 아이피 또는 대역을 설정합니다. allow-recursion { 127.0.0.1; 14.63.161.177; 192.168.0.1/24; }; // 네임서버의 zone data 정보를 남에게 보여줄 껀지 여부입니다. allow-transfer { 14.63.161.177; }; // 자체 네임서버도 사용안하며 OpenDNS를 사용하지 않으려면 주석 해제 하세요. // 단, allow-recursion는 주석처리 하셔야 합니다. //recursion no; }; //----------------------------------------------// // rndc-confgen으로 생성한 key 파일의 내용 및 key 이름을 변경해서 추가합니다. key "yongbok-key" { algorithm hmac-md5; secret "yHH6sSaUxOo8m8Fd0t+uyQ=="; }; controls { inet 127.0.0.1 port 953 allow { 127.0.0.1; } keys { "yongbok-key"; }; }; //----------------------------------------------// // root 도메인의 정보를 가지고 있는 파일을 지정 해줍니다. zone "." { type hint; file "/etc/bind/db.root"; }; //----------------------------------------------// // 네임 서버로 사용할 도메인을 지정 해줍니다. zone "yongbok.net" IN { type master; file "inverse.yongbok.net"; allow-update { 14.63.161.177; }; // Slave로 사용될 서버의 IP를 입력 합니다. allow-transfer { 14.63.161.177; }; // }; zone "164.63.14.in-addr.arpa" { type master; file "reverse.yongbok.net"; allow-update { 14.63.161.177; }; allow-transfer { 14.63.161.177; }; }; zone "0.0.127.in-addr.arpa" { type master; file "loopback.yongbok.net"; allow-update { 14.63.161.177; }; allow-transfer { 14.63.161.177; }; }; </source>
Inverse Zone 파일 생성[편집]
- 인버스 존파일은 아이피 주소를 문자로 변환 해주는 역할을 담당 합니다.
<source lang="bash">
- vi /etc/bind/db/inverse.yongbok.net
; Inverse Zone $TTL 300 @ IN SOA ns.yongbok.net. ruo91.yongbok.net. ( 2013042809 ; Serial 21600 ; Refresh 1800 ; Retry 2419200 ; Expire 86400 ) ; Negative Cache TTL ;-------------------------------------------------------------------------------------------- @ IN NS ns.yongbok.net. @ IN NS ns2.yongbok.net. ; ; MX records (Mail 서버) IN MX 10 yongbok.net.net. ; SPF 설정 yongbok.net. IN TXT "v=spf1 ip4:14.63.164.124 ~all" ; A 14.63.164.124 ns A 14.63.164.124 ns2 A 14.63.161.117 www A 14.63.164.124 ruo91 A 14.63.164.124
</source>
Revers Zone 파일 생성[편집]
- 리버스 존파일은 문자로된 도메인 주소를 아이피로 변환 해주는 역할을 담당합니다.
<source lang="c">
- vi /etc/bind/db/reverse.yongbok.net
; Reverse Zone $TTL 300 @ IN SOA ns.yongbok.net. ruo91.yongbok.net. ( 2013042809 ; Serial 21600 ; Refresh 1800 ; Retry 2419200 ; Expire 86400 ) ; Negative Cache TTL ;-------------------------------------------------------------------------------------------- @ IN NS ns.yongbok.net. @ IN NS ns2.yongbok.net. ; ; MX records (Mail 서버) IN MX 10 yongbok.net.net. ; SPF 설정 yongbok.net. IN TXT "v=spf1 ip4:14.63.164.124 ~all" ; 300 PTR ns.yongbok.net 300 PTR ns2.yongbok.net 300 PTR yongbok.net 300 PTR www.yongbok.net 300 PTR ruo91.yongbok.net
</source>
Loopback Zone 파일 생성[편집]
- 루프백 리버스 존파일도 만들어 줍니다.
<source lang="bash">
- vi /etc/bind/loopback.yongbok.net
; Loopback Zone $TTL 300 @ IN SOA ns.yongbok.net. ruo91.yongbok.net. ( 2013042809 ; Serial 21600 ; Refresh 1800 ; Retry 2419200 ; Expire 86400 ) ; Negative Cache TTL ;-------------------------------------------------------------------------------------------- @ IN NS ns.yongbok.net. @ IN NS ns2.yongbok.net. ; ; MX records (Mail 서버) IN MX 10 yongbok.net.net. ; SPF 설정 yongbok.net. IN TXT "v=spf1 ip4:14.63.164.124 ~all" ; 300 PTR localhost.
</source>
Slave 서버 설정[편집]
<source lang="bash">
- vi /etc/bind/named.conf
options { // zone file이 위치할 곳을 지정합니다. directory "/etc/bind/db"; // NXDOMAIN으로 응답 여부 (기본값 no) auth-nxdomain no; // IPv6 listen-on-v6 { any; }; // BIND 버전을 강제로 지정합니다. version "Yongbok.net"; // 자체 네임서버를 사용할 경우 허용할 아이피 또는 대역을 설정합니다. allow-recursion { 127.0.0.1; 14.63.164.124; 192.168.0.1/24; }; // 네임서버의 zone data 정보를 남에게 보여줄 껀지 여부입니다. allow-transfer { 14.63.164.124; }; // 자체 네임서버도 사용안하며 OpenDNS를 사용하지 않으려면 주석 해제 하세요. // 단, allow-recursion는 주석처리 하셔야 합니다. //recursion no; }; //----------------------------------------------// // root 도메인의 정보를 가지고 있는 파일을 지정 해줍니다. zone "." { type hint; file "/etc/bind/db.root"; }; //----------------------------------------------// // 네임 서버로 사용할 도메인을 지정 해줍니다. zone "yongbok.net" IN { type slave; // type을 slave로 변경 합니다. masters { 14.63.164.124; }; // master의 IP를 입력 합니다. file "inverse.yongbok.net"; }; zone "164.63.14.in-addr.arpa" { type slave; masters { 14.63.164.124; }; file "reverse.yongbok.net"; }; zone "0.0.127.in-addr.arpa" { type slave; masters { 14.63.164.124; }; file "loopback.yongbok.net"; };
</source>
BIND 재시작[편집]
{{#ifeq: msg|root|~|{{#ifeq: misc|root|~ service bind9 restart|{{#ifeq: root|root|ubuntu-korea|{{#ifeq: user|root|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|root|#|{{#ifeq: user|root|$|$}}}} service bind9 restart}}}}
{{#ifeq: msg|msg| * Stopping domain name service... bind [ OK ]|{{#ifeq: misc|msg| * Stopping domain name service... bind [ OK ] {{{2}}}|{{#ifeq: root|msg|ubuntu-korea|{{#ifeq: user|msg|user@ubuntu-korea|(undefined)}}}} * Stopping domain name service... bind [ OK ] {{#ifeq: root|msg|#|{{#ifeq: user|msg|$|$}}}} {{{2}}}}}}}
{{#ifeq: msg|msg| * Starting domain name service... bind [ OK ]|{{#ifeq: misc|msg| * Starting domain name service... bind [ OK ] {{{2}}}|{{#ifeq: root|msg|ubuntu-korea|{{#ifeq: user|msg|user@ubuntu-korea|(undefined)}}}} * Starting domain name service... bind [ OK ] {{#ifeq: root|msg|#|{{#ifeq: user|msg|$|$}}}} {{{2}}}}}}}
도메인 정보 확인[편집]
nslookup 명령어로 DNS 서버 정보를 확인 합니다.
{{#ifeq: msg|root|~|{{#ifeq: misc|root|~ nslookup www.yongbok.net|{{#ifeq: root|root|ubuntu-korea|{{#ifeq: user|root|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|root|#|{{#ifeq: user|root|$|$}}}} nslookup www.yongbok.net}}}}
{{#ifeq: msg|msg| Server: 8.8.8.8|{{#ifeq: misc|msg| Server: 8.8.8.8 {{{2}}}|{{#ifeq: root|msg|ubuntu-korea|{{#ifeq: user|msg|user@ubuntu-korea|(undefined)}}}} Server: 8.8.8.8 {{#ifeq: root|msg|#|{{#ifeq: user|msg|$|$}}}} {{{2}}}}}}}
{{#ifeq: msg|msg| Address: 8.8.8.8#53|{{#ifeq: misc|msg| Address: 8.8.8.8#53 {{{2}}}|{{#ifeq: root|msg|ubuntu-korea|{{#ifeq: user|msg|user@ubuntu-korea|(undefined)}}}} Address: 8.8.8.8#53 {{#ifeq: root|msg|#|{{#ifeq: user|msg|$|$}}}} {{{2}}}}}}}
{{#ifeq: msg|msg| Non-authoritative answer:|{{#ifeq: misc|msg| Non-authoritative answer: {{{2}}}|{{#ifeq: root|msg|ubuntu-korea|{{#ifeq: user|msg|user@ubuntu-korea|(undefined)}}}} Non-authoritative answer: {{#ifeq: root|msg|#|{{#ifeq: user|msg|$|$}}}} {{{2}}}}}}}
{{#ifeq: msg|msg| Name: www.yongbok.net|{{#ifeq: misc|msg| Name: www.yongbok.net {{{2}}}|{{#ifeq: root|msg|ubuntu-korea|{{#ifeq: user|msg|user@ubuntu-korea|(undefined)}}}} Name: www.yongbok.net {{#ifeq: root|msg|#|{{#ifeq: user|msg|$|$}}}} {{{2}}}}}}}
{{#ifeq: msg|msg| Address: 14.63.164.124|{{#ifeq: misc|msg| Address: 14.63.164.124 {{{2}}}|{{#ifeq: root|msg|ubuntu-korea|{{#ifeq: user|msg|user@ubuntu-korea|(undefined)}}}} Address: 14.63.164.124 {{#ifeq: root|msg|#|{{#ifeq: user|msg|$|$}}}} {{{2}}}}}}}
- DNS 점검 해보시길 권장합니다.
- 단, 시간이 어느정도 걸리므로, 시간을 넉넉잡고 시도하시는게 좋습니다.
- KISA : http://krnic.or.kr/jsp/dns/nameServerInfo/dnsCheck.jsp
- IntoDNS : http://www.intodns.com/