Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How do I convert a numeric IP address like 192.18.97.39 into a hostname like java.sun.com?

user-image
Question added by Mohd shahnawaz khan , Associate Project , Cognizant Technology Solution
Date Posted: 2014/04/16
Deleted user
by Deleted user

Is that public ip address or private LAN address.

 

considering as public IP:

 

the domain you mentioned is "java.sun.com" ie an example. where "java" is subdomain.

=> go to the cpanel of the domain and point the ip192.18.97.39 to "java", ie

create cname =java, TTL=14400 , IP=192.18.97.39

 

now  for reverse lookup or fqdn, you need to ask your ISP for PTR.

 

considering as Private IP:

set the name of the computer as "java",

put its ip address as192.18.97.39

register the computer in the domain server which is named as "sun.com" within your LAN network

 

 

Mufeed Farhan
by Mufeed Farhan , HR Applications Manager , SBM

You can use the below code :

 

package com.devdaily.javasamples;import java.net.InetAddress;import java.net.UnknownHostException;/** * Shows how to convert an IP address into a hostname. * Created by Alvin Alexander, http://devdaily.com. */public class InetAddressExample{  public static void main(String[] args)   throws UnknownHostException  {    String hostname = InetAddress.getByName("192.18.97.39").getHostName();    System.out.println("hostname = " + hostname);  }}

 

Copied from : http://alvinalexander.com/blog/post/java/java-faq-convert-ip-address-to-hostname

 

More Questions Like This