Enabling Domain Name Services:
You want to configure your router to use DNS to resolve hostnames.
To configure the router to use DNS to resolve hostnames, you need to specify a domain name and at least one nameserver:
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:
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 220.127.116.11. 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:
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:
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:
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:
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: