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 google.com server is attached to R4 and it has an IP address 44.44.44.44. R1 is trying to ping google.com. 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 google.com
DNS(config)#ip
host google.com 44.44.44.44
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)
google.com None (perm, OK)
0 IP 44.44.44.44
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 3.3.3.3
R1(config)#ip
name-server 3.3.3.3
Now let’s enable
name lookup ability on R1
R1(config)#ip domain lookup
Let’s test with ping
R1#ping google.com
Translating
"google.com"...domain server (3.3.3.3) [OK]
Type
escape sequence to abort.
Sending
5, 100-byte ICMP Echos to 44.44.44.44,
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 3.3.3.3 and that server replied that the host being fetched has an
IP address of 44.44.44.44.
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 'google.com' from 10.1.2.1(59224)
*Mar 1 00:34:34.391: DNS: Servicing request using
view default
*Mar 1 00:34:34.391: DNS: Reply
to client 10.1.2.1/59224 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
10.1.2.1/59224, 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.