How to get **all** IP addresses of a domain?

17,398

Solution 1

You could use a transparent proxy upstream of the computer(s).

For single computers, I've also used the hosts file and a special DNS server to poison DNS records by creating a false entry for facebook.com and www.facebook.com. I point it to a page somewhere with a page saying "You've been busted."

This works okay until your users figure out how to use anonymous proxies.

After a couple of steps, this really becomes a human issue. If at a business, it becomes a business policy and falls under HR. If at home, watch your kids' computer time.

Solution 2

There is not, because it's likely that the DNS server for facebook.com is only serving you with those three: it's simply not telling you about the others.

This is done for many reasons: some servers will be located close to you, geographically, and so the DNS server will prioritise those IPs to you. As a measure to curb potential DoS attacks, the DNS servers will ensure that no one person can ever know about "all" the IPs that facebook.com uses.

But mostly it's about load-balancing. Try again in an hour and you'll probably get three different IPs. This is because they want to spread the load amoung all of their servers and so the DNS will prioritize hosts that aren't getting as much traffic over those that are getting more.

Share:
17,398

Related videos on Youtube

Android Eve
Author by

Android Eve

Just starting in the world of Android development... New to Java and Eclipse as well.

Updated on September 17, 2022

Comments

  • Android Eve
    Android Eve over 1 year

    I built the getaddrinfo() sample provided at http://beej.us/guide/bgnet/html/multi/syscalls.html#getaddrinfo

    When I run it on an example domain, such facebook.com it lists three (3) IP address:

      IPv4: 69.63.189.11
      IPv4: 69.63.189.16
      IPv4: 69.63.181.12
    

    I know, however, that there are quite a few more addresses (at least 20) for facebook.com as the following answer suggests:

    http://wiki.answers.com/Q/Discuss:What_is_the_IP_address_for_Facebook

    That answer is a snapshot in time and could change in the future. I would like to be able to implement some code that would list all the IP addresses used by a domain at the time running that code.

    Is there a way to accomplish that? If so, how?

  • Admin
    Admin over 13 years
    +1 for the explanation which makes a lot of sense to me. Indeed, nslookup provides different answers at different times. I can't say that I am happy with the answer, because I am trying to find a way to block a certain domain. I know I can do that via /etc/hosts but that requires reboot or at least closing all browser instances. Is there a better way of accomplishing this?
  • gravyface
    gravyface over 13 years
    +1 for this, especially the point about policy: in my experience, completely blocking social networking had a negative productivity effect as people complained to their managers, some users tried to circumvent it by looking for proxies or tethering to their smart phones, etc. So what I've been doing now is setting up transparent proxies, logging activity, letting managers view how much time their staff are spending on any given site and dealing with it accordingly.
  • Android Eve
    Android Eve over 13 years
    Keith, thanks for your answer. I agree with your comments about the "human issue" but currently its irrelevant to the case I am trying to solve. Can you recommend such a transparent proxy (to run locally, on a single computer)?