0% found this document useful (0 votes)
26 views5 pages

Dmain Name System

Uploaded by

9923008050
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views5 pages

Dmain Name System

Uploaded by

9923008050
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

EXP NO:11 Date:

Domain Name System


Aim:
Write a program to find machine readable IP address from human readable
domain names using programming language.
Software Required:
1.Any Programming Language Software or Compiler
Theory:
A Domain Name System (DNS) is a fundamental system in the internet
infrastructure that translates human-readable domain names (like www.example.com)
into machine-readable IP addresses (like 192.0.2.1). Without DNS, we would need to
remember complex IP addresses to access websites.
How DNS Works
A Domain Name Service (DNS) is a fundamental system in the internet infrastructure
that translates human-readable domain names (like www.example.com) into machine-
readable IP addresses (like 192.0.2.1). Without DNS, remembering complex IP
addresses to access websites is required.
How DNS Works:

1. User Request: When you enter a domain name in your browser, the browser
checks its cache to see if it has the IP address saved.
2. Recursive DNS Resolver: If not in the cache, the request goes to a DNS
resolver provided by your internet service provider (ISP). This resolver acts as
a middleman.
3. Root Name Servers: The resolver queries root name servers to get information
about where to find the Top-Level Domain (TLD) name servers
(like .com, .org).
4. TLD Name Servers: These servers provide the location of the authoritative
name server for the domain.
5. Authoritative Name Server: This server contains the IP address for the
specific domain. It sends this IP back to the DNS resolver.
6. Response to Browser: The resolver sends the IP address to your browser,
which then loads the website.
Program:
import java.util.Scanner;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class DNSResolver
{
public static void main(String[] args)
{
// Obtain domain name from user input
Scanner scanner = new Scanner(System.in);
System.out.print("Enter domain name: ");
String domain = scanner.nextLine();
scanner.close();
// DNS resolution code will go here
Try
{
// Perform DNS lookup
InetAddress address = InetAddress.getByName(domain);
System.out.println("IP Address for " + domain + " is: " +
address.getHostAddress());
}
catch (UnknownHostExceptione)
{
System.out.println("Unable to resolve host: " + e.getMessage());
}
}
}

Sample Input and Output:


1. Enter domain name: www.geeksforgeeks.org
IP Address for www.geeksforgeeks.org is: 18.172.122.114
2. Enter domain name: www.google.com
IP Address for www.google.com is: 173.194.193.106

3. Enter domain name: www.facebook.com


IP Address for www.facebook.com is: 157.240.254.35
Result:
Thus the program for Domain Name System was written and output was
verified successfully.

You might also like