我怎样才能得到一个网站的IP地址?

如何获得给定网站的IP地址,如serverfault.com?

从命令提示符处:

nslookup <web site fully-qualified domain name> 

请记住,使用负载平衡器,地理DNS系统等,您获得的IP地址可能与实际分配给Web服务器的IP地址没有真正的关系。

在Linux或者Mac系统上,你也可以使用命令dig来提供一些额外的信息。 nslookup已被弃用,所以你应该在可用的地方使用dig 。 他们有类似的产出。

 $ dig serverfault.com ; <<>> DiG 9.4.3-P1 <<>> serverfault.com ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 53701 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;serverfault.com. IN A ;; ANSWER SECTION: serverfault.com. 1285 IN A 69.59.196.212 ;; Query time: 5 msec ;; SERVER: 10.0.1.1#53(10.0.1.1) ;; WHEN: Tue Jul 7 12:30:26 2009 ;; MSG SIZE rcvd: 49 

如果你这样做了很多,我会build议像ShowIP这样的Firefox加载项 。

请注意,如果Web服务器为指定的虚拟主机提供服务,那么可能会有数百甚至数千个网站“隐藏”在单个IP地址的后面。 请参阅Apache文档中的VirtualHost关键字。 即一个网站不需要有一个专用的IP地址。

ping serverfault.com在输出中查找IP地址。

 C:\Documents and Settings\user>ping serverfault.com Pinging serverfault.com [**69.59.196.212**] with 32 bytes of data: Reply from 69.59.196.212: bytes=32 time=63ms TTL=111 Reply from 69.59.196.212: bytes=32 time=58ms TTL=111 Reply from 69.59.196.212: bytes=32 time=63ms TTL=111 Reply from 69.59.196.212: bytes=32 time=67ms TTL=111 Ping statistics for 69.59.196.212: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 58ms, Maximum = 67ms, Average = 62ms 

你可能想要Alogging, host(1)是获取它的最简单的方法:

 $ host -t A serverfault.com serverfault.com has address 69.59.196.212 

dig(1)给你更多的信息:

 $ dig serverfault.com ; <<>> DiG 9.5.1-P2-RedHat-9.5.1-2.P2.fc10 <<>> serverfault.com ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 17080 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2 ;; QUESTION SECTION: ;serverfault.com. IN A ;; ANSWER SECTION: serverfault.com. 3484 IN A 69.59.196.212 <--- this is what you want ;; AUTHORITY SECTION: serverfault.com. 3484 IN NS ns22.domaincontrol.com. 

dig(1)也告诉你, ns22.domaincontrol.com是serverfault的名字服务器。 如果你想确保你得到正确的IP地址,你可以查询该名称服务器:

 $ dig @ns22.domaincontrol.com serverfault.com ; <<>> DiG 9.5.1-P2-RedHat-9.5.1-2.P2.fc10 <<>> @ns22.domaincontrol.com serverfault.com ; (1 server found) ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4726 ;; flags: qr aa; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 0 ;; QUESTION SECTION: ;serverfault.com. IN A ;; ANSWER SECTION: serverfault.com. 3600 IN A 69.59.196.212 <-- we had the right one using "host" 

在Windows中,打开命令提示符(“开始” – >“运行”,键入cmd)并运行命令:

nslookup serverfault.com

 ping serverfault.com Pinging serverfault.com [69.59.196.212] with 32 bytes of data: Reply from 69.59.196.212: bytes=32 time=189ms TTL=110 Reply from 69.59.196.212: bytes=32 time=185ms TTL=110 Reply from 69.59.196.212: bytes=32 time=185ms TTL=110 Reply from 69.59.196.212: bytes=32 time=188ms TTL=110 

如果你在只允许root用户ping的主机上:

 $ ping google.com ping: icmp open socket: Operation not permitted 

那么你可以使用wget来检查ip:

 $ wget serverfault.com -O /dev/null --21:53:22-- http://serverfault.com/ => `/dev/null' Resolving serverfault.com... 69.59.196.212 Connecting to serverfault.com|69.59.196.212|:80... connected. HTTP request sent, awaiting response... 200 OK 

作为奖励,你会知道服务器是否正常运行。

一个网站可能有多个IP – 例如,www.google.com的IP地址是什么? 那么,答案是,这取决于。 对于我来说,它是www.l.google.com的别名,它本身是64.233.161.147或64.233.161.104。

但是,如果我问一个不同的DNS服务器,我得到74.125.65.147或74.125.65.99或74.125.65.103或74.125.65.104。