1 / 13

DNS and C#

SWE 344 Internet Protocols & Client Server Programming. DNS and C#. Overview. The Internet has made the hostname a common household item.

uta
Télécharger la présentation

DNS and C#

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SWE 344 Internet Protocols & Client Server Programming DNS and C#

  2. Overview • The Internet has made the hostname a common household item. • 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.

  3. 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.

  4. 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.

  5. DNS Original Top-Level Domain Names

  6. DNS Top-Level Domains Added in 2001

  7. 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.

  8. 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: Finding a host within the local domain Finding a remote host whose name is not on the local DNS server Finding a remote host whose name is on the local DNS server cache

  9. 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

  10. 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

  11. Using a Remote DNS Server Use ping site_name ping www.yahoo.com

  12. C# program to Find DNS Server using System; using Microsoft.Win32; classFindDNSServers { publicstaticvoid Main() { RegistryKey start = Registry.LocalMachine; stringDNSservers="SYSTEM\CurrentControlSet\Services\Tcpip\Parameters"; RegistryKeyDNSserverKey = start.OpenSubKey(DNSservers); if (DNSserverKey == null) { Console.WriteLine("Unable to open DNS servers key"); return; } stringserverlist = (string)DNSserverKey.GetValue("NameServer"); Console.WriteLine("DNS Servers: {0}", serverlist); DNSserverKey.Close(); start.Close(); char[] token = newchar[1]; token[0] = ' '; string[] servers = serverlist.Split(token); foreach (string server in servers) { Console.WriteLine("DNS server: {0}", server); Console.ReadLine(); } } } DNS Servers: 10.25.0.1 10.25.0.2 DNS server: 10.25.0.1 DNS server: 10.25.0.2

  13. END

More Related