Revers Name Resolution Program code using java

PROGRAM NAME: REVERSE NAME RESOLUTION

In computer networkingreverse DNS lookup or reverse DNS resolution (rDNS) is the determination of a domain name that is associated with a given IP address using the Domain Name Service (DNS) of the Internet.

COMPLIED USING : JAVA JDK or NETBEANS IDE

CODE:



ReverseNameResolution.java

import java.net.*;
import java.util.Scanner;


class ReverseNameResolution {

    public static void main(String[] args) {

        System.out.println("Enter the IP address of the pc :-");
        Scanner in=new Scanner(System.in);
        String ip=in.nextLine();
        InetAddress inetAddress = null;
        // Get the host name given textual representation of the IP address
        try
        {
           inetAddress = InetAddress.getByName(ip);
           // Determines the IP address of a host, given the host's name.
        }
        catch (UnknownHostException e)
        {
            System.out.println("Unknown Host Exception");
            e.printStackTrace();
        }

        // The InetAddress object
        System.out.println("InetAddress object " + ip.toString());
        // Converts this IP address to a String.


        //  Gets the host name for this IP address.
        System.out.println( "Host name of " + ip + " is " + inetAddress.getHostName());

        // Gets the fully qualified domain name for this IP address.
        System.out.println("Canonical host name of " + ip + " is " + inetAddress.getCanonicalHostName());

    }

}


OUTPUT:



Enter the IP address of the pc :-
192.168.100.180
InetAddress object 192.168.100.180
Host name of 192.168.100.180 is I3-05
Canonical host name of 192.168.100.180 is I3-05

1 comments:

Anonymous said...

Very rapidly this website will be famous amid
all blogging visitors, due to it's good content

my web-site - gioco it

Post a Comment

If You Are Asking Some Question On This Comment Then Click On Subscribe by email Link