DNSのパケットキャプチャ | Network
外部サーバーに依頼
- AWS EC2 Ubuntu 20.04
- IP:10.3.0.183
$ sudo tcpdump -tnl -i eth0 udp port 53
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
Googleが管理しているオープンフルサービスリゾルバ8.8.8.8に依頼。
$ dig +short @8.8.8.8 example.org A
93.184.216.34
@8.8.8.8に名前解決を依頼する。
$ sudo tcpdump -tnl -i eth0 udp port 53
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
IP 10.3.0.183.53118 > 8.8.8.8.53: 45372+ [1au] A? example.org. (52) // --- (1)
IP 8.8.8.8.53 > 10.3.0.183.53118: 45372$ 1/0/1 A 93.184.216.34 (56) // --- (2)
(1) 10.3.0.183の53118番ポート から8.8.8.8の53番ポートに問い合わせ
(2) 8.8.8.8の53番ポートから10.3.0.183の53118番ポートに応答
53118番ポートはOSが自動採番する- 例では
digがスタブリゾルバに該当する
ポート番号
- 0 〜 1023(システムポート、ウェルノウンポート)
- 1024 〜 49151(ユーザーポート、レジスターポート)
- 49152 〜 65535(ダイナミックポート、プライベートポート)
AWS VPC フルリゾルバーに依頼
AWSのVPC内からの名前解決はAWS VPCが提供するフルリゾルバー(ホストアドレス + 2 例 10.2.0.0/16なら10.2.0.2/16)が使用される。 (@8.8.8.8のように依頼するDNSサーバを指定しない限り)
dig example.orgのように外部ドメインもVPCが提供するフルリゾルバーが参照される。
(ただし外部サーバーに依頼(@8.8.8.8)のように外部サーバを指定しない場合)
ref. AWS Route53
- VPCは
10.2.0.0/16と10.3.0.0 - インスタンスのプライベートIP
- 10.2.2.159
- 10.3.0.183 <– こちらから色々試している。
sudo tcpdump -tnl -i eth0 udp port 53
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
$ dig ip-10-2-2-159.ap-northeast-1.compute.internal
; <<>> DiG 9.16.1-Ubuntu <<>> ip-10-2-2-159.ap-northeast-1.compute.internal
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51631
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;ip-10-2-2-159.ap-northeast-1.compute.internal. IN A
;; ANSWER SECTION:
ip-10-2-2-159.ap-northeast-1.compute.internal. 60 IN A 10.2.2.159
;; Query time: 3 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Sat Apr 09 02:13:29 UTC 2022
;; MSG SIZE rcvd: 90
$ sudo tcpdump -tnl -i eth0 udp port 53
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
IP 10.3.0.183.48790 > 10.3.0.2.53: 61285+ [1au] A? ip-10-2-2-159.ap-northeast-1.compute.internal. (74) ---(1)
IP 10.3.0.2.53 > 10.3.0.183.48790: 61285 1/0/1 A 10.2.2.159 (90) ---(2)
- dig スタブリゾルバ(
10.3.0.183.48790)からフルリゾルバ(10.3.0.2.53: 61285)に依頼 - フルリゾルバ(
10.3.0.2.53: 61285)からスタブリゾルバ(10.3.0.183.48790)に返信