nslookup
和 dig
。
nslookup
是一个用于查询DNS服务器信息的工具。在命令行中输入 nslookup IP地址
即可查看对应的域名信息。例如:
$ nslookup 8.8.8.8
Server: 202.96.209.5
Address: 202.96.209.5#53
Non-authoritative answer:
8.8.8.8.in-addr.arpa name = dns.google.
dig
是一个功能更强大的DNS查询工具。在命令行中输入 dig -x IP地址
即可查看对应的域名信息。例如:
$ dig -x 8.8.8.8
; <<>> DiG 9.10.6 <<>> -x 8.8.8.8
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 63912
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;8.8.8.8.in-addr.arpa. IN PTR
;; ANSWER SECTION:
8.8.8.8.in-addr.arpa. 65432 IN PTR dns.google.
以上就是如何通过命令行工具实现IP地址到域名的转换。使用 nslookup
和 dig
可以快速获取所需信息,对于网络管理、故障排查等场景非常实用。