Saturday, October 26, 2013

Configuring a Cisco router as a Domain Name Service server (DNS server) - Basic Configuration

In the internet world, every host is identified by an IP address. The purpose of DNS (Domain Name 
Service) is to translate simple names than can be understood and memorized easily by us; humans, to those IP addresses since it will nearly impossible to memorize the IP address of all the websites you use.

Cisco’s IOS can act as a DNS server, of course it might not scale to big DNS servers out there, but it might come in handy in many situations.

Let’s check this topology

Let’s assume for a moment here that server is attached to R4 and it has an IP address R1 is trying to ping the configuration can be split into 2 parts.

1-      DNS server configuration

Let’s first enable DNS

DNS(config)#ip dns server

Now that we enabled DNS, we need to statically map the domain name to the ip address of
DNS(config)#ip host

let’s check our configuration so far

DNS#show hosts
Default domain is lab.local
Name/address lookup uses static mappings

Codes: UN - unknown, EX - expired, OK - OK, ?? - revalidate
       temp - temporary, perm - permanent
       NA - Not Applicable None - Not defined

Host                      Port  Flags      Age Type   Address(es)                None  (perm, OK)  0   IP

The configuration is pretty simple indeed, now let’s configure R1 to resolve host name via DNS router

2-   DNS client

First, let’s identify the name-server that we will send DNS requests to, in our case its IP address is
R1(config)#ip name-server

Now let’s enable name lookup ability on R1

     R1(config)#ip domain lookup

Let’s test with ping


Translating ""...domain server ( [OK]

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to, timeout is 2 seconds:
Success rate is 100 percent (5/5), round-trip min/avg/max = 40/42/48 ms

From the output shown above, it is clear that R1 used the DNS server and that server replied that the host being fetched has an IP address of

Let’s see how the DNS reacted to the request, first let’s enable the debug

DNS#debug domain
Domain Name System debugging is on

*Mar  1 00:34:34.387: DNS: Incoming UDP query (id#41532)
*Mar  1 00:34:34.387: DNS: Type 1 DNS query (id#41532) for host '' from
*Mar  1 00:34:34.391: DNS: Servicing request using view default
*Mar  1 00:34:34.391: DNS: Reply to client query A
*Mar  1 00:34:34.391: DNS: Finished processing query (id#41532) in 0.004 secs
*Mar  1 00:34:34.391: DNS: Sending response to, len 44

You can see that the server identified this as a Type-1 DNS query which means that the requester needs to resolve a hostname into an IP address, other requests like Type-2 might be for an email address and so on. The DNS query number is to identify every request on it’s own, since a single host might request many addresses, this is to distinguish them from one another.

Finally after the DNS server finds the hostname, it replies to R1 with the IP address  of the desired host.