查找域的IP地址

时间:2022-01-15 02:57:17

How can I find the IP address of an arbitrary domain? I want to get the IP address from the DNS server.

如何找到任意域的IP地址?我想从DNS服务器获取IP地址。

6 个解决方案

#1


33  

require 'socket'
IPSocket::getaddress('www.google.com') #=> "74.125.79.147"

#2


8  

Resolv is on a higher level than Socket, so will use more resources. However it has the ability to find all the ip addresses of a domain

Resolv的级别高于Socket,因此会使用更多的资源。但是,它可以找到域的所有ip地址

require 'resolv'
Resolv.getaddresses("www.ruby-lang.org")

#3


1  

Try going through the shell

试着穿过壳层

domain = "google.com"
`host #{domain}`.match(/(\d{1,3}\.){3}\d{1,3}/).to_s
#=> "74.125.39.99"

#4


1  

Try this code:

试试这段代码:

require 'resolv'
puts Resolv.getaddresses("www.panfu.dk") 

#5


0  

you always can enter http://who.is/ and enter the url of the ip you're seeking for

您总是可以输入http://who。是/并输入您要查找的ip的url吗

#6


-4  

This is the java script code which will retrun the client's IP as json object

这是java脚本代码,它将把客户端的IP转换为json对象

<script type="text/javascript">
function knowYourIP(json){
  document.write(json.ip); 
}

<script type="text/javascript" src="http://jsonip.appspot.com/?callback=knowYourIP"></script>

#1


33  

require 'socket'
IPSocket::getaddress('www.google.com') #=> "74.125.79.147"

#2


8  

Resolv is on a higher level than Socket, so will use more resources. However it has the ability to find all the ip addresses of a domain

Resolv的级别高于Socket,因此会使用更多的资源。但是,它可以找到域的所有ip地址

require 'resolv'
Resolv.getaddresses("www.ruby-lang.org")

#3


1  

Try going through the shell

试着穿过壳层

domain = "google.com"
`host #{domain}`.match(/(\d{1,3}\.){3}\d{1,3}/).to_s
#=> "74.125.39.99"

#4


1  

Try this code:

试试这段代码:

require 'resolv'
puts Resolv.getaddresses("www.panfu.dk") 

#5


0  

you always can enter http://who.is/ and enter the url of the ip you're seeking for

您总是可以输入http://who。是/并输入您要查找的ip的url吗

#6


-4  

This is the java script code which will retrun the client's IP as json object

这是java脚本代码,它将把客户端的IP转换为json对象

<script type="text/javascript">
function knowYourIP(json){
  document.write(json.ip); 
}

<script type="text/javascript" src="http://jsonip.appspot.com/?callback=knowYourIP"></script>