(선수작업)
# vi ~/.bashrc
| -------------------------(중략)---------------------------- # # DNS Server Alias # alias named.conf='vi /etc/named.conf' alias named.rfc1912.zones='vi /etc/named.rfc1912.zones' alias DNS='cd /var/named' alias dnslog='tail -f /var/log/messages' alias rsync='rsync -avz --delete -e ssh' |
: ~/.bashrc 파일의 마지막 부분에 위와 같이 추가
# . ~/.bashrc (# source ~/.bashrc)
서비스 설정 파일 작업 순서
1. # vi /etc/named.conf
2. # vi /etc/named.rfc1912.zones
3. # vi /var/named/named.ca
4. # vi /var/named/example.zone
5. # vi /var/named/example.rev
① 패키지 설치
# yum install bind bind-utils -y
: bind 설치 여부 확인 - 설치되어 있지 않다면 설치
* BIND는 DNS 서버의 기능을 제공하는 대표적인 소프트웨어로 버전에 따라 설정파일(/etc/named.conf)의 항목이 다를 수 있다
② 서비스 설정 = /etc/named.conf 파일 설정
# vi /etc/named.conf
| // // named.conf // // Provided by Red Hat bind package to configure the ISC BIND named(8) DNS // server as a caching only nameserver (as a localhost DNS resolver only). // // See /usr/share/doc/bind*/sample/ for example named configuration files. // options { listen-on port 53 { any; }; // listen-on-v6 port 53 { ::1; }; #각 도메인의 zone 파일의 위치를 지정한다 directory "/var/named"; # 정보가 갱신될 때 저장되는 파일 dump-file "/var/named/data/cache_dump.db"; # 통계파일이 생성되는 절대경로와 파일이름을 지정 statistics-file "/var/named/data/named_stats.txt"; # 메모리 관련 통계파일이 생성되는 절대경로와 파일이름을 지정 memstatistics-file "/var/named/data/named_mem_stats.txt"; secroots-file "/var/named/data/named.secroots"; recursing-file "/var/named/data/named.recursing"; allow-query { any; }; /* - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion. - If you are building a RECURSIVE (caching) DNS server, you need to enable recursion. - If your recursive DNS server has a public IP address, you MUST enable access control to limit queries to your legitimate users. Failing to do so will cause your server to become part of large scale DNS amplification attacks. Implementing BCP38 within your network would greatly reduce such attack surface */ recursion yes; dnssec-enable no; dnssec-validation no; managed-keys-directory "/var/named/dynamic"; pid-file "/run/named/named.pid"; session-keyfile "/run/named/session.key"; /* https://fedoraproject.org/wiki/Changes/CryptoPolicy */ // include "/etc/crypto-policies/back-ends/bind.config"; }; # 네임서버 실행에 있어서 디버깅시 참고할 수 있는 로그 파일 생성 위치 지정 logging { channel default_debug { file "data/named.run"; severity dynamic; }; }; # 루트 도메인에 대한 설정을 named.ca라는 파일에서 참조하라는 설정 # type과 같은 hint(루트도메인을 지정), master(1차 네임서버), slave(2차 네임서버) zone "." IN { type hint; file "named.ca"; }; include "/etc/named.rfc1912.zones"; include "/etc/named.root.key"; |
③ 주 설정 파일 설정
# vi /etc/named.rfc1912.zones
| // named.rfc1912.zones: // // Provided by Red Hat caching-nameserver package // // ISC BIND named zone configuration for zones recommended by // RFC 1912 section 4.1 : localhost TLDs and address zones // and https://tools.ietf.org/html/rfc6303 // (c)2007 R W Franks // // See /usr/share/doc/bind*/sample/ for example named configuration files. // // Note: empty-zones-enable yes; option is default. // If private ranges should be forwarded, add // disable-empty-zone "."; into options // zone "localhost.localdomain" IN { type master; file "named.localhost"; allow-update { none; }; }; zone "localhost" IN { type master; file "named.localhost"; allow-update { none; }; }; zone "1.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.loopback"; allow-update { none; }; }; zone "1.0.0.127.in-addr.arpa" IN { type master; file "named.loopback"; allow-update { none; }; }; zone "0.in-addr.arpa" IN { type master; file "named.empty"; allow-update { none; }; }; zone "example.com" IN { type master; file "example.zone"; }; zone "10.168.192.in-addr.arpa" IN { type master; file "example.rev"; }; |
# named-checkconf /etc/named.conf
- namedcheckconf 명령어는 주설정 파일(/etc/named.rfc1912.zones)의 문법을 점검하는 명령어
# named-checkconf <주설정파일의 이름>
: 아무런 메세지가 나오지 않으면 정상적으로 설정된 것
④ 힌트(Hint) 파일 생성
# cd /var/named/
# cp -p named.ca named.ca.OLD
# vi named.ca
| . 86400 IN NS ns1.com. ns1.com. 86400 IN A 192.168.10.10 |
: 기존의 힌트파일 (named.ca)은 백업 받고 새로운 파일을 만듦
* cp -p : 원본 파일의 소유자, 그룹, 권한 등 정보까지 복사
* vi 편집기 전체 선택 : Shift + v + g
전체 삭제 : d
⑤ 포워드 존 (Forward-Zone) 파일 생성 ( Domain -> IP )
# cp -p named.localhost example.zone
# vi example.zone
| $TTL 4 @ IN SOA ns1.example.com. root.example.com. ( 10 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum example.com. IN NS ns1.example.com. ns1.example.com. IN A 192.168.10.20 |
* TTL : Time To Live
4 : 기본 단위
@ : 원본 도메인
IN : Internet
SOA : Start of Authority, dl dkvdp dhsms rjtdms ehapdls dlfma
ns1.example.com. : 도메인 관리 DNS 서버
root.example.com. : 관리자의 이메일 주소
NS : Name Server
A : Address
# named-checkzone example.com exameple.zone
| zone example.com/IN: loaded serial 10 OK |
: 'OK'라고 나오면 정상적으로 설정된 것
: 형식 - "named-checkzone <Domain Name> <Zone File>"
⑥ 리버스 존 (Reverse-Zone) 파일 생성 ( IP -> Domain )
# cp -p named.loopback example.rev
# vi example.rev
| $TTL 4 @ IN SOA ns1.example.com. root.example.com. ( 10 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum IN NS ns1.example.com. 20 IN PTR ns1.example.com. |
# named-checkzone 10.168.192.in-addr.arpa example.rev
| zone 10.168.192.in-addr.arpa/IN: loaded serial 10 OK |
: 'OK'라고 나오면 정상적으로 설정
: "# named-checkzone <Domain> <Zone File>"
⑦ named.service 기동 및 확인
# systemctl enable --now named.service
# systemctl start named.service
# systemctl status named.service
| ● named.service - Berkeley Internet Name Domain (DNS) Loaded: loaded (/usr/lib/systemd/system/named.service; enabled; vendor preset: disa> Active: active (running) (thawing) since Mon 2022-01-03 16:48:52 KST; 57min ago Process: 5074 ExecStop=/bin/sh -c /usr/sbin/rndc stop > /dev/null 2>&1 || /bin/kill > Process: 5092 ExecStart=/usr/sbin/named -u named -c ${NAMEDCONF} $OPTIONS (code=exit> Process: 5089 ExecStartPre=/bin/bash -c if [ ! "$DISABLE_ZONE_CHECKING" == "yes" ]; > Main PID: 5093 (named) Tasks: 5 (limit: 11066) Memory: 61.5M CGroup: /system.slice/named.service └─5093 /usr/sbin/named -u named -c /etc/named.conf 1월 03 16:48:52 server1.example.com named[5093]: zone 10.168.192.in-addr.arpa/IN: loa> 1월 03 16:48:52 server1.example.com named[5093]: zone example.com/IN: loaded serial 10 1월 03 16:48:52 server1.example.com named[5093]: zone 1.0.0.127.in-addr.arpa/IN: load> 1월 03 16:48:52 server1.example.com named[5093]: zone localhost/IN: loaded serial 0 1월 03 16:48:52 server1.example.com named[5093]: zone 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0> 1월 03 16:48:52 server1.example.com named[5093]: zone localhost.localdomain/IN: loade> 1월 03 16:48:52 server1.example.com named[5093]: all zones loaded 1월 03 16:48:52 server1.example.com named[5093]: running 1월 03 16:48:52 server1.example.com named[5093]: managed-keys-zone: Unable to fetch D> 1월 03 16:48:52 server1.example.com named[5093]: resolver priming query complete |
# pgrep -a named
| 5093 /usr/sbin/named -u named -c /etc/named.conf |
# netstat -antup | grep :53
| tcp 0 0 192.168.10.20:53 0.0.0.0:* LISTEN 5093/named tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 5093/named tcp6 0 0 ::1:53 :::* LISTEN 5093/named udp 0 0 192.168.10.20:53 0.0.0.0:* 5093/named udp 0 0 127.0.0.1:53 0.0.0.0:* 5093/named udp 0 0 0.0.0.0:5353 0.0.0.0:* 944/avahi-daemon: r udp6 0 0 ::1:53 :::* 5093/named udp6 0 0 :::5353 :::* 944/avahi-daemon: r |
* 옵션
-a : all
-n : num
-t : tcp
-u : udp
-p : protocol
⑨ 방화벽에 서비스 등록
# firewall-cmd --permanent --add-service=dns
# firewall-cmd --reload
# firewall-cmd --list-all
| public (active) target: default icmp-block-inversion: no interfaces: ens33 sources: services: cockpit dhcpv6-client dns ssh ports: protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules: |
: dns 가 들어있는지 확인
⑩ /etc/resolv.conf 수정 또는 DNS 서비스 확인
# nmcli connection modify ens33 ipv4.dns 192.168.10.20 ipv4.dns-search example.com
# nmcli connection up ens33
# cat /etc/resolv.conf
| # Generated by NetworkManager search example.com nameserver 192.168.10.20 |
<------TUI방식------->
# nmtui
DNS Server : 192.168.10.20
Search Domains : example.com으로 변경
# nmcli connection up ens33
# cat /etc/resolv.conf로 확인 - 정상적으로 나오는지 확인
▷ 정상적으로 정보 요청이 가능한지 확인
# nslookup ns1.example.com
# nslookup 192.168.10.20
'Linux > 3) 리눅스 네트워크 관리자 과정' 카테고리의 다른 글
| 03_3 DNS Server - DNS(Domain Name System) 동작 원리 (0) | 2021.09.17 |
|---|---|
| 03_2 DNS Server - 도메인(Domain) 관련 용어 (0) | 2021.09.17 |
| 03_1 DNS Server - DNS(Domain Name System) 개요 (0) | 2021.09.17 |
| 02_01 SELinux(Security Enhanced Linux) - SELinux 적용 모드 변경 (0) | 2021.09.05 |
| 01_04_01 Network Configuration Administration - 본딩 (Bonding) (0) | 2021.09.02 |