1. DNS/実装/python/dnslib/example/client
ソース: https://github.com/paulc/dnslib/blob/master/dnslib/client.py
tmaeno@skr:~/dnslib-master/dnslib$ python3 client.py --help usage: client.py [-h] [--server <address:port>] [--query] [--hex] [--tcp] [--noretry] [--diff DIFF] [--dig] [--short] [--dnssec] [--debug] <domain> [<type>] DNS Client positional arguments: <domain> Query domain <type> Query type (default: A) optional arguments: -h, --help show this help message and exit --server <address:port>, -s <address:port> Server address:port (default:8.8.8.8:53) (port is optional) --query Show query (default: False) --hex Dump packet in hex (default: False) --tcp Use TCP (default: UDP) --noretry Don't retry query using TCP if truncated (default: false) --diff DIFF Compare response from alternate nameserver (format: address:port / default: false) --dig Compare result with DiG - if ---diff also specified use alternative nameserver for DiG request (default: false) --short Short output - rdata only (default: false) --dnssec Set DNSSEC (DO/AD) flags in query (default: false) --debug Drop into CLI after request (default: false)
tmaeno@skr:~/dnslib-master/dnslib$ python3 client.py qmail.jp A ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55565 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;qmail.jp. IN A ;; ANSWER SECTION: qmail.jp. 21599 IN A 127.0.0.128 tmaeno@skr:~/dnslib-master/dnslib$ python3 client.py qmail.jp NS ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64087 ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;qmail.jp. IN NS ;; ANSWER SECTION: qmail.jp. 21599 IN NS b.ns.qmail.jp. qmail.jp. 21599 IN NS 14.192.44.5.