[英]Finding the IP address of a domain
How can I find the IP address of an arbitrary domain? 如何找到任意域的IP地址? I want to get the IP address from the DNS server.
我想从DNS服务器获取IP地址。
require 'socket'
IPSocket::getaddress('www.google.com') #=> "74.125.79.147"
Resolv is on a higher level than Socket, so will use more resources. Resolv比Socket更高级别,因此将使用更多资源。 However it has the ability to find all the ip addresses of a domain
但是它能够找到域的所有IP地址
require 'resolv'
Resolv.getaddresses("www.ruby-lang.org")
Try this code: 试试这段代码:
require 'resolv'
puts Resolv.getaddresses("www.panfu.dk")
Try going through the shell 尝试浏览shell
domain = "google.com"
`host #{domain}`.match(/(\d{1,3}\.){3}\d{1,3}/).to_s
#=> "74.125.39.99"
你总是可以输入http://who.is/并输入你正在寻找的ip的网址
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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.