DNS : Java Glossary


DNS
DNS (Domain Name Service). The name lookup the Internet uses to convert from alphabetic names such as oberon.ark.com to 32-bit binary IPv4 (Internet Protocol Version 4) or 128-bit IPv6 (Internet Protocol Version 6) addresses used on packet routing. There are computers spread all over the Internet called DNS servers. They will automatically look up a name for you and give you the equivalent numeric IP. The process is analogous to looking up somone’s name in an electronic phone book to find out their phone number. This happens completely automatically whenever you key a website name into your browser or FTP (File Transfer Protocol) client.
IP addresses The Miracle of DNS
Explicit DNS Lookup Caching
Discovering your Host Name Clearing DNS Cache
Discovering your DNS Server Suffix
How DNS Works Links

IP (Internet Protocol) addresses

IPv4 addresses are displayed for humans as a dotted quad with four numbers 0..255, e.g. as 204.50.21.34. In Windows 95/98/ME/NT/W2K/XP/W2K3 there is an auxiliary DNS helper file called HOSTS. that lists pairs of domain names and dotted quads. You can use this file for commonly looked up names, or for local names, e.g. names of workstations on the LAN (Local Area Network). This is considerably quicker than getting one of the DNS servers to do those lookups for you.

Explicit DNS Lookup

In Java, you can invoke DNS lookup to convert the name to the dotted quad IP address by:

Discovering your Host Name

The InetAddress class also lets you work backwards from the dotted quad to get the host name.

Discovering your DNS Server

There is no official way in Java to find out the IP or name of your default DNS server, e.g. the one that DHCP (Dynamic Host Configuration Protocol) assigned you. DNSjava is a pure Java set of classes to add a DNS server to your application. That is a rather large hammer to deal with the problem. In  Java version 1.3 you need the name of a DNS server to use JNDI to get at the other DNS information. In Java version 1.4 or later, here is how you get at

For a LAN, you can assign IP addresses such as 192.168.0.1, 192.168.0.2 to each station since these are never seen on the Internet. In Windows, you can use the utility ipconfig /all to display information such as DNS Server IP, host name, physical ethernet 48-bit MAC (Media Access Control) address, IP, subnet mask, gateway IP and DHCP server IP. In older versions of Windows there is a similar utility called winipconfig.

How DNS Works

Here is my current best understanding about how the DNS lookup works. Don’t quote me yet.

There is a master database of all DNS names and their corresponding IP names. It is not stored all in one computer, but to simplify the explanation, we will pretend that it is. Some DNS names have associated several IPs (Internet Protocols) of server farms that are assigned on a round robin basis to share the workload.

www.mindprod.com, mail.mindprod.com and mindprod.com may all translate to different IPs or to the same IP. All three are tracked in the master database. Ordinary humans aren’t allowed to talk to this master database. Instead you talk to a DNS server run by your local ISP (Internet Service Provider). It does not have the entire database in it, just the entries most popular with the clients of your ISP. If you ask your ISP DNS server for a name it does not know, it asks a higher level server. If that higher level server does not know, it asks still a higher level server, working all the way back to the master DNS database server.

Does this mean you pester the master database every time you ask for a non-existent DNS name? Yes, but since the master database is actually entirely replicated in many computers, this is not the bottleneck you might expect.

How are changes propagated? Roughly once a day each DNS server asks the next higher level server if each of the entries it has cached in its local database is still valid. If not, it drops each invalid entry from its local database. If somebody later asks for that DNS name, the server will asks the next higher level server.

The master database server, through a tree of helpers, periodically asks every station on the net if its DNS name to IP translations are still valid, and if not, what the new information is. The information percolates up so that the master database is then completely up-to-date. From the master database, the information gradually percolates back down to all the ISP servers, through the ordinary process of asking the next higher level server when a server does not have a name in its cache. Information does not percolate down until it is needed. It generally takes about two days for out-of-date information to be totally flushed out of the system. How long it takes depends on a configurable freshness date for each name.

This way your computer only has to tell the Internet once about a DNS change. It does not have to directly tell every DNS server on the Internet.

What goes wrong is sometimes servers refuse to delete invalid cached entries. Then the only way to clear the out-of-date information is to reboot them and clear the entire cache. NT DNS servers have this problem. When a server fails to invalidate its cache, all downstream servers will be badly (i.e. weeks) out-of-date as well. The problem is not cleared until that server is rebooted.

DNS can do a number of other things besides convert a domain name to an IP number. It can go the other way, starting with an IP, figure out the DNS name. It can find out the latitutude and longitude of the server hosting the domain. It can find out what kind of CPU (Central Processing Unit) the server is. It can find out who owns the domain. It can distribute digital certificates. It can tell you the name of the associated mail servers. In Java you access this additional information with JNDI.

DNS Cache

Windows caches DNS lookups for speed. The problem is if a DNS server is down and comes back up, Windows will not immediately notice. You can clear the cache to make Windows look afresh to the Internet with ipconfig /flushdns. You must run from the command line as administrator.
book cover recommend book⇒DNS and BIND, fifth editionto book home
by Cricket Liu, Paul Albitz 978-0-596-10057-5 paperback
publisher O’Reilly recommended 978-0-596-55340-1 eBook
published 2006-06-02 B0026OR2QS kindle
Covers up to version 9.1.0 BIND. Also cover IPv6. This explains how Domain Name Service finds the corresponding IP to a name. BIND in the software that usually comes bundled with Unix for letting you manange your little branch of the DNS name tree.
Australian flag abe books anz abe books.co.uk UK flag
Chinese flag amazon.cn amazon.co.uk UK flag
German flag abe books.de abe books.ca Canadian flag
German flag amazon.de amazon.ca Canadian flag
Spanish flag amazon.es Chapters Indigo Canadian flag
Spanish flag iberlibro.com abe books.com American flag
French flag abe books.fr amazon.com American flag
French flag amazon.fr Barnes & Noble American flag
Italian flag abe books.it Google play American flag
Italian flag amazon.it O’Reilly Safari American flag
India flag junglee.com Powells American flag
UN flag Kobo other stores UN flag

The Miracle of DNS

The most amazing thing about the Internet is how conceptually simple it is and how low tech. In the end, the whole DNS lookup service rests on little flat files prepared with a text editor, (e.g. notepad), that list the names of the domains you own and the IPs they live at, and the nameservers who will handle last resort queries about this domain if the caches don’t already know. This humble but authoritive information gets propagated in multilevel caches in nameservers all over the Internet. It works similarly for the mail system — little flat files, prepared by the owner of each domain, with MX records in them, telling where to find the mail server for the owner’s domain. Each nameserver knows about just some of the Internet. For the rest, it forwards requests to a better-informed nameserver, or asks a better informed nameserver on the caller’s behalf, who in turn may delegate the request, perhaps right back the master authorative nameserver for that domain. One problem with this hierarchical approach is it puts a heavy load on the master servers for top level domains like .com

The IP routing system can also be controlled by simple flat files. Each router looks at the IP of the incoming packet and determines which band (low/high) it belongs in, and has a table which node to send all packets in that band to, hopefully a step closer to their destinations. Some bands may have several destinations to share the load. Clever routers can start forwarding a packet even before it has fully arrived.

Caching

The DNS lookup services of the native OS (Operating System) can be very slow. So Java caches the results. You can control how long a DNS to IP lookup remains fresh in the cache with two entries in the java.security files.

Look for the networkaddress.cache.ttl TTL (Time To Live) networkaddress.cache.negative.ttl. Documentation on using them is embedded in the comments in the java.security file.

You can also set the security properties programmatically with:

// setting cache time to live to 10 seconds
java.security.Security.setProperty( "networkaddress.cache.ttl" , "10" );

Clearing DNS Cache

To clear the DNS cache:

  1. Run the command interpreter (command prompt) as administrator.
  2. Type ipconfig /flushdns.

If you use DHCP, your router or IAP (Internet Access Provider) will provide the IP of the DNS servers automatically, so you don’t have to configure them. Typing ipconfig at the command prompt will display the names of the DNS servers. If you suspect one of your DNS servers is not working properly, you can use ipconfig /renew to ask your IAP to resend the list.

DNS Connection-Specific Suffix

You can use short names such us shawmail or shawnews instead of spelling out the name in full shawmail.glb.shawcable.net or shawnews.gv.shawcable.net if you set up a connection-specific prefix to use as a default suffix to append to short names. You can do it like this: Control Panel ⇒ network and sharing center ⇒ manage network connections ⇒ right click the connection ⇒ properties ⇒ TCP/IP4 ⇒ advanced ⇒ DNS ⇒ append these DNS suffixes
Can others reach some website down for you?
Configuring an alternate DNS server
DHCP
DNS for Rocket Scientists: free online book
DNSJava a tool for DNS lookup written in pure Java
DNSStuff: all manner of web tools for DNS/IP
domain names
Dyn: three free services of interest to people who host webservers on their home machines
Google public DNS servers
hosts
Internet troubleshooting
IP
IPv6
JNDI
local domain
localhost
Networking Properties
RFC 1876: how latitude and longitude are stored in a DNS record
SOA records
TCP/IP
TTL
whois

This page is posted
on the web at:

http://mindprod.com/jgloss/dns.html

Optional Replicator mirror
of mindprod.com
on local hard disk J:

J:\mindprod\jgloss\dns.html
logo
Please the feedback from other visitors, or your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.
Blog
IP:[65.110.21.43]
Your face IP:[54.198.142.4]
You are visitor number