CertificationCiscoHow to

How to Enabling Cisco Domain Name Services

Enabling Domain Name Services:

Problem
You want to configure your router to use DNS to resolve hostnames.

Solution
To configure the router to use DNS to resolve hostnames, you need to specify a domain name and at least one nameserver:

Router1#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
Router1(config)#ip domain-lookup
Router1(config)#ip domain-name oreilly.com
Router1(config)#ip name-server 172.25.1.1 
Router1(config)#ip name-server 10.1.20.5 
Router1(config)#end
Router1#

 

Starting in IOS Version 12.2, Cisco changed the command syntax from ip domain-lookup to ip domain lookup. They also changed the command syntax from ip domain-name to ip domain name. The new IOS software still accepts previous versions of the commands.

 

Discussion

you can configure your router to use Domain Name Service (DNS) to resolve hostnames. In fact, Cisco routers have DNS name resolution enabled by default. However, since there is no default nameserver, the router will attempt to use the local broadcast address, 255.255.255.255, until you explicitly configure a proper nameserver. This means that the ip domain-lookup configuration command in the example is necessary only if someone has explicitly disabled DNS on the router.

After you configure the router with a valid nameserver, you can access any hostname that is known by your DNS server. For example, our DNS server exchanges information with the public Internet, so we can ping the Cisco web page by name:

Router1#ping www.cisco.com
Translating "www.cisco.com"...domain server (172.25.1.1) [OK]

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 198.133.219.25, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 80/91/104 ms
Router1#

You can see in this output that the router sent a DNS query to the nameserver, 172. 25.1.1, and asked it to translate the hostname www.cisco.com. The server responded with an IP address of 198.133.219.25. The router then behaved as if we had simply asked it to ping this destination IP address instead of the hostname.

In this example, we configure multiple nameservers:

Router1(config)#ip name-server 172.25.1.1
Router1(config)#ip name-server 10.1.20.5 

The router will send its queries to these servers in the order that we entered them. For example, suppose we tried to ping a factitious host, www.ITcapsula.com:

Router1#ping www.ITcapsula.com
Translating "www.ITcapsula.com"...domain server (172.25.1.1)(10.1.20.5)
% Unrecognized host or address, or protocol not running.

Router1#

As you can see, the router sent this query first to the nameserver at 172.25.1.1. When this device was unable to resolve the name, the router resorted to the second nameserver, 10.1.20.5. Ultimately the query failed because the hostname doesn’t exist.

You can view the DNS configuration parameters with the show hosts command:

Router1#show hosts
Default domain is oreilly.com
Name/address lookup uses domain service
Name servers are 172.25.1.1, 10.1.20.5

Host                      Port  Flags      Age Type   Address(es)
www.cisco.com             None  (temp, OK)  0   IP    198.133.219.25
Router1#

This command displays the domain name, the nameservers (in their order of preference), as well recently resolved hostnames. The router keeps a name cache of recently resolved names to prevent unnecessary DNS lookups on successive attempts to the same host. The difference between these dynamically learned hosts and the statically configured ones that we saw last chapter is that the router will automatically flush the dynamic entries from the cache after a period of time. This time period is actually specified by the DNS server separately for each hostname, so you cannot change it on the router.

The ip domain-name command allows you to specify your network’s domain name:

Router1(config)#ip domain-name ITcapsula.com

When you configure a domain name like this, you can work with just the local hostname instead of the Fully Qualified Domain Name (FQDN). For example, you could type mail instead of mail.ITcapsula.com, and the router would resolve it correctly.

The show hosts command output includes the domain list:

Router1#show hosts
Default domain is oreilly.com
Domain list: ora.com, oreilly.com
Name/address lookup uses domain service
Name servers are 172.25.1.1, 172.25.1.3, 10.1.20.5

Host                      Port  Flags      Age Type   Address(es)
www.cisco.com             None  (temp, OK)  0   IP    198.133.219.25
freebsd                   None  (perm, OK)  0   IP    172.25.1.1
Router1#

 

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

MXtb iXL 3a

Please type the text above:

Check Also

Close
Close
Close