dnsmasq는 경량의 리눅스 DNS캐시 서버 , 리눅스 서버는 기본적으로로 DNS캐시를 수행하지 않으나 dnsmasq를 활용하여 DNS캐시로 활용할수 있음
일반적으로 사용하는 Public DNS서버
# KT
168.126.63.1
168.126.63.2
# Google
8.8.8.8
8.8.4.4
# Cloudflare
1.1.1.1
주로사용하는 DNS 서버는 nscd, named, dnsmasq가 있음
여기에서는 dnsmasq를 활용한 localdns 캐시 설정 하는 방법을 기록함
CentOS 및 RHEL Linux에 dnsmasq 설치
1. dnsmasq 패키지는 기본저장소에서 사용할수 있음 (YUM 패키지 관리자로 설치 가능)
# DNS 캐시 서버 설치
yum install dnsmasq or dns install dnsmasq
# nslookup, dig DNS 질의 도구 설치
yum install bind-utils
2. DNS캐시 적용
# DNS 캐시할 목록 작성
$ sudo nano /etc/hosts
127.0.0.1 localhost
::1 localhost
# 설치한 DNS 캐시 서버로 DNS 질의되도록 지정
vi /etc/resolv.conf
nameserver 127.0.0.1
# DNS 캐시 서버에 없는 도메인 요청을 질의할 DNS 서버를 지정
vi /etc/resolv.dnsmasq
nameserver 168.126.63.1
nameserver 168.126.63.2
mv /etc/dnsmasq.conf /etc/dnsmasq.conf.bak
vi /etc/dnsmasq.conf
# somewhere other that /etc/resolv.conf
resolv-file=/etc/resolv.dnsmasq
# Set the cachesize here.
cache-size=500
##ttl-override
min-cache-ttl=3600
# config 변경후 syntax 오류등 체크
#config test
dnsmasq --test
# DNS 캐시 서버 재시작
# DNS 캐시를 초기화하는 역할도 수행(dnsmasq cache clear가 필요할때는 재기동해야함)
service dnsmasq restart
# DNS 캐시 서버 자동 시작 활성화
service enable dnsmasq
# DNS 캐시 서버 동작 확인
nslookup dragonfog.net
# DNS 캐시 서버 동작 확인 (TTL 정보까지 확인) - bind-utils 설치 해줘야 사용 가능
dig dragonfog.net
config sample
# Server Configuration
listen-address=127.0.0.1
port=53
bind-interfaces
#user=dnsmasq
#group=dnsmasq
pid-file=/var/run/dnsmasq.pid
conf-dir=/etc/dnsmasq.d,.rpmnew,.rpmsave,.rpmorig
log-facility=/var/log/dnsmasq.log
no-hosts
log-queries
log-async=50
clear-on-reload
# Name resolution options
resolv-file=/etc/resolv.dnsmasq
addn-hosts=/etc/hosts.dnsmasq
cache-size=1500
neg-ttl=60
domain-needed
bogus-priv
min-cache-ttl=3600
3. query 로그 설정후 logrotate
## /etc/lgorotate.d/dnsmasq
echo -e "/var/log/dnsmasq.log
{
missingok
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/dnsmasq.pid 2> /dev/null` 2> /dev/null || true
endscript
}" >> /etc/logrotate.d/dnsmasq
참고 :
https://aws.amazon.com/ko/premiumsupport/knowledge-center/dns-resolution-failures-ec2-linux/
https://ko.linux-console.net/?p=537#gsc.tab=0
https://wiki.gentoo.org/wiki/Dnsmasq/ko
CentOS / RHEL 8/7에서 dnsmasq를 사용하여 DNS / DHCP 서버를 설정하는 방법
CentOS / RHEL 8/7에서 dnsmasq를 사용하여 DNS / DHCP 서버를 설정하는 방법 DHCP (Dynamic Host Configuration Protocol) 서버는 네트워크의 각 장치에 IP 주소 및 기타 네트워크 구성 매개 변수를 동적으로 할당합니
ko.linux-console.net
[Linux] Centos 7 dnsmasq를 이용한 local dns 구축
dnsmasq는 DNS Forward / Cache / DHCP 기능 수행 Master 1. yum install dnsmasq 2. /etc/hosts 에 서비스할 로컬 domain 들을 적어줍니다.127.0.0.1 localhost192.168.0.10 master192.168.0.11 slave1192.168.0.12 slave1 3. /etc/resolv.conf 에 names
sysops.tistory.com
EC2 Linux에서 DNS 확인 실패 방지
닫기 Gian의 동영상을 보고 자세히 알아보기(4:33)
aws.amazon.com
'OS > CentOS' 카테고리의 다른 글
| SSL 체크 스크립트 (0) | 2023.05.11 |
|---|---|
| dnsmasq 설치 후 질의 통계 확인 하기 (0) | 2023.01.16 |
| openssl 버전업 (CentOS 7.x에서 openssl 버전업) (0) | 2022.02.22 |
| [CentOS 6/7/8] EPEL 과 Remi Repo 설치 하기 (0) | 2021.11.23 |
| CMD를 이용해서 위치정보 조회 (0) | 2021.08.13 |