LPIC201/202 あずき本 ch9 DNS (1/3)

DNSLPIC202勉強メモ資格勉強

出典: 

9.1 DNSの基本

9.1.1 名前解決

www.example.com.
  • www: ホスト名
  • example.com.: ドメイン名
  • www.example.com.: FQDN: 完全修飾ドメイン名

9.1.2 DNSの仕組み

  • 再帰的問い合わせ

    • スタブリゾルバ -> フルリゾルバ への問い合わせ
  • 非再帰的問い合わせ

    • フルリゾルバ -> 権威サーバ への問い合わせ

JRPSの「DNSがよくわかる教科書」で学習済

※LPICではフルリゾルバをキャッシュサーバ、権威サーバをコンテンツサーバと呼ぶよう

9.1.3 DNSサーバ

BIND

  • 代表的なDNSソフトウェア
  • フルリゾルバ兼権威サーバ

ゾーン

  • DNSサーバが管轄するドメイン範囲

    • 管理権限をもつことを「権威を持つ」という
    • 親はゾーンカットして子に「権限を委譲」する

マスターDNSサーバ、スレーブDNSサーバ

冗長化する

  • ゾーン転送

    • マスター->スレーブへゾーン情報を転送すること

再帰的な問い合わせ

  • スタブリゾルバ->フルキャッシュリゾルバへの、最終的な結果を要求する問い合わせのこと
  • 【補】cf. 非再帰的な問い合わせ

    • フルキャッシュリゾルバから権威サーバへの問い合わせ
    • 「知っている情報を教えてください」という問い合わせ
    • 「この権威サーバーに委譲してるよ」という応答が返ることがある。つまり、最終的な結果が得られるとは限らない

Column: BIND以外のDNSサーバ

  • dnsmasq

    • DNS権威サーバ+フルキャッシュリゾルバ+DHCP
  • djbdns

    • DNS権威サーバ+フルキャッシュリゾルバ 機能分割していて安全性が高い
    • 開発終了済
  • PowerDNS

    • DNS権威サーバ+フルキャッシュリゾルバ
    • RDBバックエンド

9.1.4 DNSクライアントコマンド

nslookup

古株

nslookup google.com
-bash: nslookup: command not found

ないので入れる

yum provides nslookup
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ty1.mirror.newmediaexpress.com
 * epel: d2lzkl7pfhq30w.cloudfront.net
 * extras: ty1.mirror.newmediaexpress.com
 * updates: ty1.mirror.newmediaexpress.com
32:bind-utils-9.11.4-26.P2.el7.x86_64 : Utilities for querying DNS name
                                      : servers
Repo        : base
Matched from:
Filename    : /usr/bin/nslookup



32:bind-utils-9.11.4-26.P2.el7_9.2.x86_64 : Utilities for querying DNS name
                                          : servers
Repo        : updates
Matched from:
Filename    : /usr/bin/nslookup



32:bind-utils-9.11.4-26.P2.el7_9.3.x86_64 : Utilities for querying DNS name
                                          : servers
Repo        : updates
Matched from:
Filename    : /usr/bin/nslookup

bind-utilsパッケージでdig等ともども入る

sudo yum install -y bind-utils
nslookup google.com
Server:		169.254.169.254
Address:	169.254.169.254#53

Non-authoritative answer:
Name:	google.com
Address: 172.217.31.174
Name:	google.com
Address: 2404:6800:4004:80c::200e

Non-authoritative answer:

「権威のない応答」:フルリゾルバがキャッシュを返している

権威サーバに問い合わせると権威のある応答を得る

nslookup -type=NS google.com
Server:		169.254.169.254
Address:	169.254.169.254#53

Non-authoritative answer:
google.com	nameserver = ns4.google.com.
google.com	nameserver = ns2.google.com.
google.com	nameserver = ns1.google.com.
google.com	nameserver = ns3.google.com.

Authoritative answers can be found from:
nslookup google.com ns1.google.com.
Server:		ns1.google.com.
Address:	216.239.32.10#53

Name:	google.com
Address: 216.58.220.142
Name:	google.com
Address: 2404:6800:4004:813::200e

引数なし: 対話モード

nslookup
> server 1.1.1.1
Default server: 1.1.1.1
Address: 1.1.1.1#53
> google.com
Server:		1.1.1.1
Address:	1.1.1.1#53

Non-authoritative answer:
Name:	google.com
Address: 172.217.25.206
Name:	google.com
Address: 2404:6800:4004:81a::200e
> server ns1.google.com.
Default server: ns1.google.com.
Address: 216.239.32.10#53
Default server: ns1.google.com.
Address: 2001:4860:4802:32::a#53
> google.com
Server:		ns1.google.com.
Address:	216.239.32.10#53

Name:	google.com
Address: 216.58.220.142
Name:	google.com
Address: 2404:6800:4004:813::200e
> exit

IPアドレス指定すると逆引き

nslookup 216.58.220.142
142.220.58.216.in-addr.arpa	name = nrt20s17-in-f14.1e100.net.
142.220.58.216.in-addr.arpa	name = syd09s01-in-f142.1e100.net.

Authoritative answers can be found from:

host

ホスト名指定: 正引き

host google.com

A,AAAA,MXが返ってくる

google.com has address 172.217.31.174
google.com has IPv6 address 2404:6800:4004:80c::200e
google.com mail is handled by 20 alt1.aspmx.l.google.com.
google.com mail is handled by 10 aspmx.l.google.com.
google.com mail is handled by 50 alt4.aspmx.l.google.com.
google.com mail is handled by 30 alt2.aspmx.l.google.com.
google.com mail is handled by 40 alt3.aspmx.l.google.com.

-t: レコードタイプ指定

host -t A google.com
google.com has address 172.217.31.174
host -t AAAA google.com
google.com has IPv6 address 2404:6800:4004:80c::200e

IPアドレス指定すると逆引き

host 172.217.31.174
174.31.217.172.in-addr.arpa domain name pointer nrt12s22-in-f14.1e100.net.
  • -v: verbose. DNS応答表示
  • 第2引数: フルリゾルバ
host -v -t A google.com 1.1.1.1
Trying "google.com"
Using domain server:
Name: 1.1.1.1
Address: 1.1.1.1#53
Aliases: 

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52797
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;google.com.			IN	A

;; ANSWER SECTION:
google.com.		164	IN	A	172.217.25.206

Received 44 bytes from 1.1.1.1#53 in 6 ms

dig

dig google.com
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.3 <<>> google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 44990
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;google.com.			IN	A

;; ANSWER SECTION:
google.com.		299	IN	A	172.217.26.46

;; Query time: 7 msec
;; SERVER: 169.254.169.254#53(169.254.169.254)
;; WHEN: Tue Dec 29 16:11:09 UTC 2020
;; MSG SIZE  rcvd: 55
  • -x: 逆引き
dig -x 172.217.26.46
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.3 <<>> -x 172.217.26.46
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21244
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;46.26.217.172.in-addr.arpa.	IN	PTR

;; ANSWER SECTION:
46.26.217.172.in-addr.arpa. 21599 IN	PTR	nrt12s17-in-f46.1e100.net.
46.26.217.172.in-addr.arpa. 21599 IN	PTR	nrt12s17-in-f14.1e100.net.

;; Query time: 130 msec
;; SERVER: 169.254.169.254#53(169.254.169.254)
;; WHEN: Tue Dec 29 16:11:19 UTC 2020
;; MSG SIZE  rcvd: 124

flags: qr rd ra

  • qr:

    • 問い合わせに対する解答
  • aa:

    • authoritative answer. 権威のある応答
  • rd:

    • 再帰検索を希望
  • ra:

    • 再帰検索が可能

非再帰問い合わせで権威応答を得る場合:

dig google.com @ns1.google.com. +norecurse
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.3 <<>> google.com @ns1.google.com. +norecurse
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 31221
;; flags: qr aa; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;google.com.			IN	A

;; ANSWER SECTION:
google.com.		300	IN	A	216.58.220.142

;; Query time: 89 msec
;; SERVER: 216.239.32.10#53(216.239.32.10)
;; WHEN: Tue Dec 29 16:15:10 UTC 2020
;; MSG SIZE  rcvd: 55

flags: qr aa;