Finding the IP address of a domain

后端 未结 6 520
别那么骄傲
别那么骄傲 2021-01-04 01:52

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

相关标签:
6条回答
  • 2021-01-04 02:07

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

    0 讨论(0)
  • 2021-01-04 02:11
    require 'socket'
    IPSocket::getaddress('www.google.com') #=> "74.125.79.147"
    
    0 讨论(0)
  • 2021-01-04 02:11

    Try going through the shell

    domain = "google.com"
    `host #{domain}`.match(/(\d{1,3}\.){3}\d{1,3}/).to_s
    #=> "74.125.39.99"
    
    0 讨论(0)
  • 2021-01-04 02:12

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

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

    <script type="text/javascript" src="http://jsonip.appspot.com/?callback=knowYourIP"></script>
    
    0 讨论(0)
  • 2021-01-04 02:18

    Try this code:

    require 'resolv'
    puts Resolv.getaddresses("www.panfu.dk") 
    
    0 讨论(0)
  • 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

    require 'resolv'
    Resolv.getaddresses("www.ruby-lang.org")
    
    0 讨论(0)
提交回复
热议问题