The Domain Name System (DNS)

Download Report

Transcript The Domain Name System (DNS)

SWE 344
Internet Protocols & Client Server
Programming
DNS and C#
Overview

The Internet has made
common household item.
the
hostname
a

Because of this, almost all network programs
must allow customers to enter hostnames as
well as IP addresses, and it is up to the
network programmer to ensure that the
program can find the IP address that is
properly associated with the hostname.

The
primary
control
mechanism
for
accomplishing this is the Domain Name
System (DNS), which is used to control
hostnames and provide information to hosts
wanting to find the IP address of another
hostname.
2
The Domain Name System (DNS)
 To simplify the unwieldy state of computer naming,
the Domain Name System (DNS) was created. It
allows the master host database to be split up and
distributed among multiple systems on the
Internet.
 DNS uses a hierarchical database approach,
creating levels of information that can be split and
stored on various systems throughout the
Internet.
 DNS also provides a means for clients to query the
database in real time.
 If the client queries a DNS server with a hostname
not stored on the DNS server’s local database, the
server can query another DNS server that does
have the information and forward it to the client. 3
DNS Structure
 The top node is called the root.
 Multiple categories were created under the root level to divide
the database into pieces called domains.
 Each domain contains DNS servers that are responsible for
maintaining the database of computer names for that area of the
database.
The top level of distribution is divided into domains based on country
codes. Additional top-level domains for specific organizations were
created to prevent the country domains from getting overcrowded.
4
DNS Original Top-Level Domain Names
Domain
Description
.com
Commercial organizations
.edu
Educational institutions
.mil
U.S. military sites
.gov
U.S. government organizations
.net
Internet Service Providers (ISPs)
.org
Nonprofit organizations
.us
Other U.S. organizations (such as local
governments)
.ca
Canadian organizations
.de
German organizations
(other countries)
Organizations from other countries
5
DNS Top-Level Domains Added in 2001
Domain
Description
.aero
Corporations in the air transport industry
.biz
Generic businesses
.coop
Cooperatives
.info
Unrestricted use
.museum
Museums
.name
Individuals
.pro
Professionals (doctors, lawyers, and so on)
6
Domain and subdomain on the Internet
 As the Internet grows, the top-level domains are each divided into
subdomains, or zones. Each zone is an independent domain in
itself but relies on its parent domain for connectivity to the
database. A parent zone must grant permission for a child zone to
exist and is responsible for the child zone’s behavior.
 Each zone must have at least two DNS servers that maintain the
DNS database for the zone.
7
Finding a Hostname in DNS
DNS enables clients to query a local DNS server to
obtain hostname information. This process results in
three possible scenarios for finding a hostname:
1. Finding a host within the local domain
2. Finding a remote host whose name is not on the
local DNS server
3. Finding a remote host whose name is on the local
DNS server cache
8
The DNS Database
 Each DNS server is responsible for keeping track of the hostnames
in its zone.
 To accomplish this, the DNS server must have a way to store host
information in a database that can be queried by remote machines.
 The DNS database is a text file that consists of resource records
(RRs) for hosts and network functions in the zone.
smallorg.org IN SOA master.isp.net. postmaster.master.isp.net
postmaster.master.isp.net (
1999080501 ;unique serial number 8H ;
refresh rate 2H ;retry period 1W ;
expiration period 1D) ; minimum
NS ns1.isp.net. ;defines primary namserver
NS ns2.isp.net. ;defines secondary nameserver
MX 10 mail1.isp.net. ; defines primary mail server
MX 20 mail2.isp.net. ; defines secondary mail
server www CNAME host1.isp.net ;defines a www server at the ISP
ftp CNAME host1.isp.net ; defines an FTP server at the ISP
host1.isp.net A
10.0.0.1 1.0.0.10.IN-ADDR.ARPA PTR host1.isp.net ; pointer for reverse DNS
Sample DNS database entries
9
Windows DNS Client Information
The hostnames file is named hosts, and its location depends on which version
of Windows you are using:

For Windows 95, 98, Me, and XP, hosts is located in the
C:\WINDOWS\SYSTEM32\DRIVERS\ETC directory.

For Windows NT, and 2000, hosts is located in the
C:\WINNT\SYSTEM32\DRIVERS\ETC directory.

The hosts file is in text format, with each line representing a record for
each host. The host IP address is listed first, followed by one or more
spaces and then the hostname; for example:
127.0.0.1 localhost 192.168.1.1 shadrach.blum.lan 192.168.1.2
meshach.blum.lan 192.168.1.6 abednego.blum.lan
10
Using a Remote DNS Server
Use ping site_name
 ping www.yahoo.com11
C# program to Find DNS Server
using System;
using Microsoft.Win32;
class FindDNSServers
{
public static void Main()
{
RegistryKey start = Registry.LocalMachine;
string DNSservers ="SYSTEM\CurrentControlSet\Services\Tcpip\Parameters";
RegistryKey DNSserverKey = start.OpenSubKey(DNSservers);
if (DNSserverKey == null)
{
Console.WriteLine("Unable to open DNS servers key");
return;
}
string serverlist = (string)DNSserverKey.GetValue("NameServer");
Console.WriteLine("DNS Servers: {0}", serverlist);
DNSserverKey.Close();
start.Close();
char[] token = new char[1];
token[0] = ' ';
string[] servers = serverlist.Split(token);
foreach (string server in servers)
{
DNS Servers: 10.25.0.1
Console.WriteLine("DNS server: {0}", server);
10.25.0.2
Console.ReadLine();
}
DNS server: 10.25.0.1
}
DNS server: 10.25.0.2
}
12
END
13