Results 1 to 4 of 4
  1. #1
    Mor
    Mor is offline Member
    Join Date
    Oct 2013
    Posts
    2
    Rep Power
    0

    Default InetAddres - Can't retrieve some FQDM from IP addresses

    Hi,
    I'm trying to retrieve a FQDM from IP address by using InetAddress without success

    my JAVA program:

    Java Code:
    public static void main(String[] args)	{ 
    
    String result = ""; 
    
    String ipAddress = new IPAddress(args[0]); 
    
       try { 
          result = Inet6Address.getByName(ipAddress).getHostName(); 
       } catch (UnknownHostException e) { 
          System.out.println("Error in DNSLocator#getNameToResolve"); 
       } 
    
       System.out.println("IP- "+ipAddress +" NAME- "+result); 
    
    }
    For the input: 125.56.199.115
    I receive: IP- 125.56.199.115 NAME- 125.56.199.115

    --------------------------------------------------------------

    Using ping -a command:

    Pinging a125-56.199-115.deploy.akamaitechnologies.com [125.56.199.115] with 32 bytes of data:
    Reply from 125.56.199.115: bytes=32 time=409ms TTL=45
    Reply from 125.56.199.115: bytes=32 time=397ms TTL=45

    --------------------------------------------------------------

    Using nslookup command :

    nslookup 125.56.199.115
    Server: 172.17.0.10
    Address: 172.17.0.10#53

    Non-authoritative answer:
    115.199.56.125.in-addr.arpa name = a125-56.199-115.deploy.akamaitechnologies.com

    --------------------------------------------------------------

    What can be the cause? how Java resolve ip to name? What is the difference between Java and nslookup/ping??

    I tried to add -Dsun.net.spi.nameservice.provider.1=dns,sun
    but it's still not works.

    Thanks.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: InetAddres - Can't retrieve some FQDM from IP addresses

    From the API:
    "
    Returns:
    the host name for this IP address, or if the operation is not allowed by the security check, the textual representation of the IP address.
    "
    So it's quite possible that there is a security issue?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    Mor
    Mor is offline Member
    Join Date
    Oct 2013
    Posts
    2
    Rep Power
    0

    Default Re: InetAddres - Can't retrieve some FQDM from IP addresses

    I debug code, the function in InetAddress check security but System.getSecurityManager() returns null so checkConnect not checked and security exception doesn't thrown

    if (check) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
    security.checkConnect(host, -1);
    }
    }

    I see that nameService.lookupAllHostAddr(host) retrieve UnknownHostException

    For some IPs it works, for example:
    System.out.println("IP 23.5.165.18 "+""+ "Name- "+InetAddress.getByName("23.5.165.18").getHostName ());
    IP 23.5.165.18 Name- a23-5-165-18.deploy.static.akamaitechnologies.com

    But some IPs for some IPs not, for example:
    System.out.println("IP -125.56.199.115 "+ "Name- "+InetAddress.getByName("125.56.199.115").getCanon icalHostName());
    IP- 125.56.199.115 Name- 125.56.199.115

    these addresses accessible and you can also try to resolve this IPs
    Do you have another idea of what could be the reason?

    Thanks.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: InetAddres - Can't retrieve some FQDM from IP addresses

    Different DNS maybe?
    Getting a bit out of my field...:)
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Arrays memory addresses
    By Dayanand in forum New To Java
    Replies: 2
    Last Post: 03-04-2011, 10:17 AM
  2. Validation for multiple email addresses
    By dushyant1244 in forum Advanced Java
    Replies: 0
    Last Post: 09-24-2010, 07:00 AM
  3. Replies: 3
    Last Post: 01-19-2008, 07:05 AM
  4. how to read memory addresses
    By fred in forum New To Java
    Replies: 1
    Last Post: 07-24-2007, 02:59 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •