Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resolving ip-address of a hostname

Tags:

java

I have the DNS server IP address and a hostname.

Using Java, how can I find the IP address of the hostname as returned by that DNS server using the IP address and the hostname?

like image 383
Dark Matter Avatar asked Apr 03 '13 13:04

Dark Matter


People also ask

Why does IP address not resolve to a hostname?

If the DNS for your hostname is not set up correctly, you may receive an email saying something similar to this: Your hostname (srv.example.com) could not be resolved to an IP address. This means that /etc/hosts is not set up correctly, and/or there is no dns entry for srv.example.com.

What does resolve a hostname mean?

Hostname Resolution refers to the process through which an assigned hostname is converted or resolved to its mapped IP Address so that networked hosts can communicate with each other. This process can either be achieved locally on the host itself or remotely through a designated host configured to serve that purpose.

What is the process of resolving a hostname or FQDN to an IP address?

Host Name Resolution is the process by which a host determines the IP address of another host given its host name or fully qualified domain name (FQDN) on a TCP/IP network.


1 Answers

Take a look at InetAddress and the getHostAddress() method.

InetAddress address = InetAddress.getByName("www.example.com");  System.out.println(address.getHostAddress());  
like image 90
thegrinner Avatar answered Sep 29 '22 19:09

thegrinner