Dnsmasq

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Dnsmasq and the translation is 66% complete.
Outdated translations are marked like this.
Resources
Resources

dnsmasq는 1000 클라이언트 이하의 로컬 네트워크에서 활용하 수 있는 간단한 DHCP/DNS 서버입니다. 핵심 특징으로는 쉬운 설정과 소규모 시스템을 꼽을 수 있습니다. IPv6를 지원하기도 합니다.

설치

USE flags

dnsmasq 설치는 꾸러미 관리자와 포티지 트리에서 완벽하게 지원합니다. 먼저 적당한 USE 플래그를 선택하십시오.

USE flags for net-dns/dnsmasq Small forwarding DNS server

auth-dns Add support for acting as an authorative DNS server.
conntrack Add support for Linux conntrack connection marking.
dbus Enable dbus support for anything that needs it (gpsd, gnomemeeting, etc)
dhcp Enable support for acting as a DHCP server.
dhcp-tools Install extra command line tools for manually managing DHCP leases.
dnssec Enable support DNSSEC validation and caching.
dumpfile Include code to dump packets to a libpcap-format file for debugging
id Whether report *.bind CHAOS info to clients, otherwise forward such requests upstream instead
idn Enable support for Internationalized Domain Names
inotify Enable inotify filesystem monitoring support
ipv6 Add support for IP version 6
libidn2 Enable support for Internationalized Domain Names, via net-dns/libidn2 rather than net-dns/libidn
loop Include functionality to probe for and remove DNS forwarding loops
lua Enable Lua scripting support
nettlehash Use hashing functions from dev-libs/nettle
nls Add Native Language Support (using gettext - GNU locale utilities)
script Enable support for calling scripts when leases change.
selinux !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur
static !!do not set this during bootstrap!! Causes binaries to be statically linked instead of dynamically
tftp Enables built in TFTP server for netbooting.

Emerge

다음, net-dns/dnsmasq를 설치하고 자동으로 시작하게 하려면 기본 런레벨에 추가하십시오.

root #emerge --ask net-dns/dnsmasq

설정

dnsmasq 동작을 바꿀 수 있도록 하는 다양한 참고 자료가 있습니다. 해당 참고자료로,

  • /etc/conf.d/dnsmasq로 제공하는 명령줄 옵션
  • /etc/dnsmasq.conf 주 설정 파일

Service

OpenRC

Add dnsmasq to the default runlevel if it needs to be started automatically:

root #rc-update add dnsmasq default

To start the service now:

root #rc-service dnsmasq start

서비스 설정

/etc/conf.d/dnsmasq에서 설정할 수 있는 명령줄 옵션은 시작할 때 dnsmasq 데몬에 전달합니다.

파일 /etc/conf.d/dnsmasqdnsmasq 서비스 설정 예제
DNSMASQ_OPTS="--user=dnsmasq --group=dnsmasq -H /srv/virt/gentoo/hosts --max-cache-ttl=10"

주 설정 파일

dnsmasq의 주 설정은 /etc/dnsmasq.conf 자체 설정 파일로 처리할 수 있습니다. 이 파일에서는 key[=value] 문법을 활용하며, 패키지에서 제공하는 설정 파일은 잘 설명되어 있기 때문에 읽어 본 후 다루어보시기를 권장합니다. 파일 도는 명령 줄 옵션을 통해(DHCP hosts 파일과 같은) 추가 참고 요소를 참고할 수 있습니다.

설정 파일 보기는 다음과 같습니다:

파일 /etc/dnsmasq.conf
# Listen only to this interface
interface=eth1
  
# Assign names based on mac address
dhcp-host=00:1e:68:c2:ff:ee,endor,192.168.0.54,24h
  
# Any other DHCP request gets an ip from this range
dhcp-range=eth1,192.168.0.100,192.168.0.120,12h
  
# Enable the TFTP server and set the root directory for files available via TFTP.
enable-tftp
tftp-root=/var/lib/tftpboot
dhcp-boot=/pxelinux.0

설정 파일을 편집하고 나면 서비스를 다시 시작해야 합니다. 다시 읽기를 지원하지만, 다른 참고 요소에 대해서만 지원합니다.

root #/etc/init.d/dnsmasq restart

hosts 파일

dnsmasq 프로그램은 -h (--no-hosts) 명령줄 매개변수를 전달하지 않는 한 DNS 서비스를 제공하려는 목적으로 참고 요소 중 하나인 /etc/hosts 파일을 활용합니다.

/etc/hosts 파일을 업로드하면, dnsmasq 서비스는 설정을 다시 읽으려 SIGHUP 시그널을 받아야 합니다. 스크립트의 reload 명령이 이 동작을 지원합니다:

root #/etc/init.d/dnsmasq reload

설정 파일에서 no-hosts 매개변수를 활용하여 이 동작을 비활성화 할 수 있습니다.

추가 hosts 파일

DNS 요청 소스로 활용할 (추가) hosts 파일을 참고할 수 있습니다. 이렇게 하려면 명령행 옵션에 -H /path/to/hostsfile (--addn-hosts=/path/to/hostsfile) 옵션을 추가하십시오. 이 옵션으로 디렉터리도 전달할 수 있습니다. 이 경우, 해당 디렉터리에 있는 모든 파일을 추가 hosts 파일로 간주합니다.

표준 hosts 파일과 비슷하게 SIGHUP 시그널로 파일을 다시 불러옵니다.

설정 파일에서 addn-hosts 매개변수를 활용하여 이 동작을 설정할 수 있습니다.

업스트림 네임 서버

기본적으로 dnsmasq는 /etc/resolv.conf 에 지정된 네임 서버를 업스트림 네임 서버로 사용합니다.

다른 파일은 -r (--resolv-file) 명령줄 옵션을 통해 사용할 수 있습니다.

설정 파일에서 resolv-file 매개변수를 활용하여 이 동작을 설정할 수 있습니다.

기능

dnsmasq는 DNS, TFTP, PXE, 라우터 알림, DHCP 서비스를 지원합니다. 중소규모 네트워크용 네트워크 관리 도구로서 안성맞춤입니다.

DNS 서비스

DNS 서비스 (만) 제공하려면, 우선 사용할 업스트림 네임 서버를 식별해야 합니다. 동일한 네임 서버를 /etc/resolv.conf 에 지정했다면 추가로 해야 할 일은 없습니다. 그렇지 않으면, -r (--resolv-file) 명령줄을 활용하여 적당한 resolv.conf 파일을 dnsmasq에 알려주어야 합니다. 이 문법은 dnsmasq가 nameserver 정의만 보긴 하지만, /etc/resolv.conf 파일에서 활용합니다.

예를 들자면:

root #echo "nameserver 8.8.8.8" >> /etc/dnsmasq.conf.resolv

다음 dnsmasq를 설정 파일에서 이 파일로 가리키도록 하십시오:

파일 /etc/dnsmasq.conf사용자 정의 resolv 파일 설정
resolv-file=/etc/dnsmasq.conf.resolv

서비스가 실행중(설정 파일을 바꿔서 다시 시작한 후)인지 확인하려면, (net-dns/bind-tools에 있는)dig 명령을 사용하여 로컬 주소 또는 원격 주소를 해석할 DNS 서버(다음 예제에서는 localhost에서 실행)에 요청하십시오.

user $dig @localhost +short www.gentoo.org
www-bytemark-v4v6.gentoo.org.
89.16.167.134

DNSSEC

dnsmasq에서는 데이터를 전달하여 DNSSEC 데이터를 검증할 수 있습니다. 설정 파일에 다음 줄을 추가하시면 됩니다:

파일 /etc/dnsmasq.confDNSSEC 활성화
# DNSSEC setup
dnssec
trust-anchor=.,19036,8,2,49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE32F24E8FB5
dnssec-check-unsigned
  1. Replies which are not DNSSEC signed may be legitimate, because the domain
  2. is unsigned, or may be forgeries. Setting this option tells dnsmasq to
  3. check that an unsigned reply is OK, by finding a secure proof that a DS
  4. record somewhere between the root and the domain does not exist.
  5. The cost of setting this is that even queries in unsigned domains will need
  6. one or more extra DNS queries to verify.

dnssec-check-unsigned }}

신뢰 앵커는 다음 iana.org 사이트에서 찾을 수 있습니다. 이 내용을 바꾸면 dnsmasq에서 SERVFAIL을 반환하며 검증에 실패하면 DNS 데이터를 제공하지 않습니다. 검증에 성공하면 ad 플래그를 설정합니다. 이 경우 도메인에서는 이전과 마찬가지로 DNSSEC dnsmasq 동작을 지원하지 않습니다.

DHCP 서비스

dnsmasq의 DHCP 서비스를 활성화하려면, dhcp-range 설정을 활용하십시오.

예를 들어, 무한 대여시간동안 RA로 IPv6 주소 설정과 IPv4 주소 설정을 활성화하려면:

파일 /etc/dnsmasq.confIPv6와 IPv4 대여 활성화
dhcp-range=2001:db8:81:e2::,ra-only,infinite
dhcp-range=192.168.100.100,192.168.100.149,infinite

알려진 호스트에 대해 정적 정의를 활용할 수 있는데, 주 설정 파일 (dhcp-host= 설정)을 통해 활용할 수도 있고, 파일로 따로 나누어 활용할 수도 있습니다. 파일을 따로 나누어 활용할 경우에는 dnsmasq에게 --dhcp-hostsfile 명령줄 옵션을 활용하여 알리십시오. 파일을 따로 나누어 활용하는 방법의 이점은 설정 파일의 정의를 다시 불러오려면 서비스를 완전히 다시 시작해야 하지만, 항목을 다시 불러오려면 해당 항목에 따라 SIGHUP 시그널(또는 서비스 다시 읽기)을 보낸다는 점입니다.

dhcp-host 매개변수 문법을 더 알아보시려면 설명서 페이지를 참고하시거나 더 확장할 수 있는 문법을 설명한 설정 파일을 참고하십시오.

사용법

이 장에서는 dnsmasq 서비스의 다양한 사용 상황(관리, 운영 작업)을 다룹니다.

대여 초기화

클라이언트 측에서 MAC 주소가 달라지는 네트워크 인터페이스 업데이트 동작은 의도한 IP 주소를 바로 가져오지 못합니다. dnsmasq 서비스는 이전 MAC 주소를 기반으로 IP 주소를 제공하기 때문이며, 다시 할당하기 전에는 이 주소 대여 기간이 끝날 때까지 기다려야합니다.

dnsmasq 서비스는 /var/lib/misc/dnsmasq.leases에 대여 정보를 저장합니다. 대여 설정에서 더 이 내용을 더 빨리 제거해야 한다면 dnsmasq 서비스를 내리고 dnsmasq.leases 파일에서 대여 정보를 제거한 후 서비스를 다시 시작하십시오.

root #/etc/init.d/dnsmasq stop
root #nano -w /var/lib/misc/dnsmasq.leases
root #/etc/init.d/dnsmasq start

비주류 설정 다시 불러오기

다음 dnsmasq.conf 파일에서, dnsmasq 서비스에 다음 서비스를 외부 정의로 활용할 수 있습니다:

  • DHCP 호스트 설정 항목(--dhcp-hostsfile 명령 줄 옵션)
  • DHCP 옵션(--dhcp-optsfile 명령줄 옵션)

이 파일을 수정했을 때 설정 파일을 다시 불러오려 SUGHUP 시그널에서 dnsmasq를 취합니다.(?? 주: 원문의 표현이 조금 이상함)

참고
resolv.conf 파일은 dnsmasq에서 기본으로 찾아봅니다. -n (--no-poll) 명령행 옵션을 설정하기 전 또는 no-poll 설정 매개변수를 사용하지 않는 한 파일에서 바뀐 내용은 자동으로 불러옵니다.