0

I have been trying several methods in some of the posts to get the actual Public Address from an IP(like facebook.com), but I have not been successful so far. I have been trying the below code to get the web address of facebook :

import java.net.InetAddress;
import java.net.UnknownHostException;

public class Main {
    public static void main(String args[]) throws UnknownHostException {
        InetAddress addr = InetAddress.getByName("31.13.76.68");
        String host = addr.getHostName();
        System.out.println(host);
    }
}

But what it returns me is this: edge-star-mini-shv-01-sea1.facebook.com. Is this the CNAME that is getting returned? I get the same results with getCanonicalHostName. Some websites even return corp address with gives me no information of the actual public address that IP is associated with. Is there a way to get the actual public address for a given IP? say 31.13.76.68 returns facebook.com, and 74.125.196.100 should return google.com and not yk-in-f100.1e100.net as I am getting in my case.

learn_develop
  • 1,735
  • 4
  • 15
  • 33

0 Answers0