。゚(*´□`)゚。

코딩의 즐거움과 도전, 그리고 일상의 소소한 순간들이 어우러진 블로그

[네이버클라우드] 클라우드 기반의 개발자 과정 7기/리눅스

7일 차 ,, bind

quarrrter 2023. 5. 3. 00:43

지피티야 bind가 뭐니,,!!!!!!

bind는 DNS(Domain Name System) 서버를 구현하는 데 사용되는 오픈 소스 소프트웨어입니다. DNS 서버는 도메인 이름을 IP 주소로 변환하는데 사용되며, 인터넷에서 웹 사이트를 검색하거나 이메일을 보내는 등의 작업에서 필수적인 역할을 합니다.

bind는 DNS 클라이언트가 DNS 서버에게 쿼리를 보내면 이를 받아서 해당하는 도메인 이름의 IP 주소를 반환하는 역할을 합니다. 이를 위해 bind는 DNS 정보를 데이터베이스로 유지하고, DNS 요청이 들어오면 이를 처리하여 결과를 반환합니다.

 

 

 

/etc/bind# vi named.conf.options
 
21     dnssec-validation no;   // auto ==> no
 22     recursion yes;
 23     allow-query { any; };
 24     listen-on-v6 { any; };

cd  /etc/bind
vi  named.conf.default-zones

 30 zone "it.kr" {
 31     type master;
 32     file "/etc/bind/it.zone";
 33 };
 34
 35 zone "20.50.100.in-addr.arpa" {
 36     type master;
 37     file "/etc/bind/it.rev";
 38 };
 39
root@ijj:/etc/bind# cp db.local  it.zone
root@ijj:/etc/bind# vi it.zone

  1 $TTL    604800
  2 @   IN  SOA ns.it.kr.   master.it.kr. (
  3                   2     ; Serial
  4              604800     ; Refresh
  5               86400     ; Retry
  6             2419200     ; Expire
  7              604800 )   ; Negative Cache TTL
  8 @   IN  NS  ns.it.kr.
  9     IN  A   100.50.20.10
 10 ns  IN  A   100.50.20.10
 11 www IN  A   100.50.20.20
 12 ftp IN  A   100.50.20.30
 13 mail    IN  A   100.50.20.40
 14 sun     IN  CNAME   www

 cp it.zone it.rev
root@ijj:/etc/bind# vi it.rev

 1 $TTL    604800
  2 @   IN  SOA ns.it.kr.   master.it.kr. (
  3                   2     ; Serial
  4              604800     ; Refresh
  5               86400     ; Retry
  6             2419200     ; Expire
  7              604800 )   ; Negative Cache TTL
  8 @   IN  NS  ns.it.kr.                                                  
  9     IN  A   100.50.20.10
 10     IN  PTR it.kr.
 11 10  IN  PTR ns.it.kr.
 12 20  IN  PTR www.it.kr.
 13 20  IN  PTR sun.it.kr.
 14 30  IN  PTR ftp.it.kr.
 15 40  IN  PTR mail.it.kr.

root@ijj:~# systemctl  restart named
root@ijj:~# nslookup
> server 127.0.0.1
Default server: 127.0.0.1
Address: 127.0.0.1#53
> it.kr
;; communications error to 127.0.0.1#53: timed out
Server:         127.0.0.1
Address:        127.0.0.1#53

Name:   it.kr
Address: 100.50.20.10
> www.it.kr
;; communications error to 127.0.0.1#53: timed out
Server:         127.0.0.1
Address:        127.0.0.1#53

Name:   www.it.kr
Address: 100.50.20.20
> ftp.it.kr
Server:         127.0.0.1
Address:        127.0.0.1#53

Name:   ftp.it.kr
Address: 100.50.20.30
> mail.it.kr
Server:         127.0.0.1
Address:        127.0.0.1#53

Name:   mail.it.kr
Address: 100.50.20.40
> sun.it.kr
Server:         127.0.0.1
Address:        127.0.0.1#53

sun.it.kr       canonical name = www.it.kr.
Name:   www.it.kr
Address: 100.50.20.20
> 100.50.10.10
;; communications error to 127.0.0.1#53: timed out
** server can't find 10.10.50.100.in-addr.arpa: SERVFAIL
> 100.50.20.10
;; communications error to 127.0.0.1#53: timed out
10.20.50.100.in-addr.arpa       name = ns.it.kr.
> 100.50.20.20
;; communications error to 127.0.0.1#53: timed out
20.20.50.100.in-addr.arpa       name = www.it.kr.
20.20.50.100.in-addr.arpa       name = sun.it.kr.
> 100.50.20.30
30.20.50.100.in-addr.arpa       name = ftp.it.kr.
> 100.50.20.40
40.20.50.100.in-addr.arpa       name = mail.it.kr.
>
▶ 도전 과제 
nc.zone   nc.rev를 만드시오.

Domain: nc.co.kr
200.100.50.10 ns.nc.co.kr
200.100.50.20 www.nc.co.kr
200.100.50.30 ftp.nc.co.kr
200.100.50.40 mail.nc.co.kr
CNAME web www


조건> it.zone it.rev 파일 복사해서 쓰면 안됨 

[출처] NC-7기 7일차 리눅스 수업 (양주종의 코딩스쿨 ▶ C언어 ·파이썬 ·리눅스 ·정보처리기사) | 작성자 양주종

 

 

내가 정리한거


리눅스

root@psh:~# nslookup
> naver.com
Server:         127.0.0.53
Address:        127.0.0.53#53

sever 8.8.8.8  변경

/////
bind9 인터넷에서 사용되는 DNS(Domain Name System) 서버의 소프트웨어 중 하나입니다. 

alias aq='apt list --installed | grep '
ai bind9
systemctl start bind9(=named)
systemctl status bind9
systemctl restart bind9


방화벽 확인
ufw status
상태: 비활성

root1(152p)
root@psh:~# cd /etc/bind/
vi named.conf

     8  include "/etc/bind/named.conf.options";
     9  include "/etc/bind/named.conf.local";
    10  include "/etc/bind/named.conf.default-zones";


*vi /etc/bind/named.conf.options
수정 및 추가 

21     dnssec-validation no;   // auto ==> no
 22     recursion yes;
 23     allow-query { any; };
 24     listen-on-v6 { any;};
 25
 26     listen-on-v6 { any; };
 27 };

systemctl restart named

----------------------------------------------- 그냥 각 파일이 하는 역할 봄 
*vi named.conf.local
구경만,,

*vi named.conf.default-zones
  9
 10 zone "localhost" {                     //localhost 관련해서 물어보면 아래 파일에서 알려주겠다
 11     type master;
 12     file "/etc/bind/db.local";


root@psh:/etc/bind# nl db.local
     1  ;
     2  ; BIND data file for local loopback interface
     3  ;
     4  $TTL    604800   //시간 
     5  @       IN      SOA     localhost. root.localhost. (
     6                                2         ; Serial
     7                           604800         ; Refresh
     8                            86400         ; Retry
     9                          2419200         ; Expire
    10                           604800 )       ; Negative Cache TTL
    11  ;
    12  @       IN      NS      localhost.
    13  @       IN      A       127.0.0.1
    14  @       IN      AAAA    ::1

역방향 의무는 없음 
---------------------------------------------------
root@psh:/etc/bind# vi named.conf.default-zones


 30 zone "it.kr" {
 31     type master;
 32     file "/etc/bind/it.zone";
 33 }
 34
 35 zone "20.50.100.in-addr.arpa" {
 36     type master;
 37     file "/etc/bind/it.rev";
 38 }





root@psh:/etc/bind# cp db.local it.zone
root@psh:/etc/bind# vi it.zone

 1 $TTL    604800
  2 @   IN  SOA ns.it.kr.   master.it.kr. (
  3                   2     ; Serial
  4              604800     ; Refresh
  5               86400     ; Retry
  6             2419200     ; Expire
  7              604800 )   ; Negative Cache TTL
  8 @   IN  NS  ns.it.kr.
  9     IN  A   100.50.20.10
 10 ns  IN  A   100.50.20.10
 11 www IN  A   100.50.20.20
 12 ftp IN  A   100.50.20.30
 13 mail    IN  A   100.50.20.40
 14 sun     IN  CNAME   www


root@psh:/etc/bind# cp it.zone it.rev
cp: 'it.rev'을(를) 덮어쓸까요? y
root@psh:/etc/bind# vi it.rev

 12 @   IN  NS  ns.it.kr.
 13 @   IN  A   100.50.20.10
 14     IN  PTR it.kr.
 15 10  IN  PTR ns.it.kr.
 16 20  IN  PTR www.it.kr.
 17 20  IN  PTR sun.it.kr.
 18 30  IN  PTR ftp.it.kr.
 19 40  IN  PTR mail.it.kr.
~


systemctl restart named
nslookup
> server 127.0.0.1
Default server: 127.0.0.1
Address: 127.0.0.1#53
> it.kr
;; communications error to 127.0.0.1#53: timed out
Server:         127.0.0.1
Address:        127.0.0.1#53