获得域名的IP地址dig,nslookup

dig和nslookup都可以实现,但是nslookup不稳定,已经不推荐使用,建议使用dig。

yum install bind bind-utils -y

用法:
dig www.google.com AAAA
第一个参数是要查询的域名,第二个参数AAAA是记录类型,A就是IPv4地址(默认就是A),AAAA就是ipv6地址
返回结果看;; ANSWER SECTION:下面那一行,就是对应的域名和IP
示例:

[root@xxx ~]# dig www.google.com

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6_7.4 <<>> www.google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 33728
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

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

;; ANSWER SECTION:
www.google.com. 275 IN A 216.58.192.36

;; Query time: 62 msec
;; SERVER: 2001:4860:4860::8844#53(2001:4860:4860::8844)
;; WHEN: Wed Nov 18 02:10:52 2015
;; MSG SIZE rcvd: 48
[root@xxx ~]# dig www.google.com AAAA

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6_7.4 <<>> www.google.com AAAA
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52826
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;www.google.com. IN AAAA

;; ANSWER SECTION:
www.google.com. 270 IN AAAA 2607:f8b0:4005:803::2004

;; Query time: 52 msec
;; SERVER: 2001:4860:4860::8844#53(2001:4860:4860::8844)
;; WHEN: Wed Nov 18 02:12:47 2015
;; MSG SIZE rcvd: 60

Add a Comment

电子邮件地址不会被公开。 必填项已用*标注

4 + 18 =