/*****************************
* Author : Samson
* Date : 12/06/2015
* Test platform:
* gcc 4.8.4
* GNU bash, 4.3.30
* Debian GNU/Linux 8
* ***************************/
很多时候,需要对域名进行解析,那么在GNU Linux下有什么好的工具可以使用呢?
大部分时间我们只需要使用ping命令即可完成这个工作,但是ping命令对于有域名对应多个IP的情况并不能够完整地进行得到,那么以下就介绍下能够得到完整的域名对应的IP地址,主要有三个命令可以完成如上的功能需求:
1、host
2、dig
3、nslookup
以下将以www.bing.com域名进行解析的使用如下:
~/ $ dig www.bing.com
dig www.bing.com
; <<>> DiG 9.9.5-3-Ubuntu <<>> www.bing.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 11805
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 3
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.bing.com. IN A
;; ANSWER SECTION:
www.bing.com. 354 IN CNAME cn.a-0001.a-msedge.net.
cn.a-0001.a-msedge.net. 47 IN A 202.89.233.101
;; AUTHORITY SECTION:
a-msedge.net. 161755 IN NS ns1.a-msedge.net.
a-msedge.net. 161755 IN NS ns2.a-msedge.net.
;; ADDITIONAL SECTION:
ns1.a-msedge.net. 161755 IN A 204.79.197.1
ns2.a-msedge.net. 161755 IN A 131.253.21.1
;; Query time: 38 msec
;; SERVER: 127.0.1.1#53(127.0.1.1)
;; WHEN: Sun Dec 06 19:21:17 CST 2015
;; MSG SIZE rcvd: 161
~/ $ host www.bing.com
host www.bing.com
www.bing.com is an alias for cn.a-0001.a-msedge.net.
cn.a-0001.a-msedge.net has address 202.89.233.101
~/ $ nslookup www.bing.com
nslookup www.bing.com
Server: 127.0.1.1
Address: 127.0.1.1#53
Non-authoritative answer:
www.bing.com canonical name = cn.a-0001.a-msedge.net.
Name: cn.a-0001.a-msedge.net
Address: 202.89.233.101
ubuntu下暂时不能解析域名“us.archive.ubuntu.com”:http://www.linuxdiyf.com/linux/15936.html
Linux无法解析域名的解决办法:http://www.linuxdiyf.com/linux/504.html
ubuntu不能解析域名No address associated with hostname:http://www.linuxdiyf.com/linux/14009.html