Domain Name System or DNS is considered as the phonebook of the Internet. DNS servers resolve domain names to IP addresses. Google Public DNS (22.214.171.124 and 126.96.36.199) is an example of free DNS services and can replace your ISP’s default DNS server addresses.
Configuring Cisco Routers as DNS Servers
A Cisco router can act as both a Domain Name System cache name server (DNS resolver) and as an authoritative name server for local hosts. The cache name server stores the DNS queries so that it can answer requests quickly without having to query authoritative servers for each transaction.
1. Using the sample network topology above, let’s configure the IP address first on each device.
Cisco Router (DNS) – 172.16.0.1/24
DNS(config)#interface GigabitEthernet0/0 DNS(config-if)#ip address 172.16.0.1 255.255.255.0
Server (dnstest.lab) – 172.16.0.2/24
#ifconfig eth0 Link encap:Ethernet HWaddr 00:50:00:00:06:00 inet addr:172.16.0.2 Bcast:172.16.0.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:136 errors:0 dropped:0 overruns:0 frame:0 TX packets:183 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:12343 (12.0 KiB) TX bytes:52120 (50.8 KiB)
PC1 – IP address 172.16.0.3, Mask /24, Gateway 172.16.0.1
Primary DNS Server – 172.16.0.1
Let’s leave the secondary DNS server blank.
2. Enable DNS service in global configure mode on our Cisco router.
DNS(config)#ip dns server
3. Configure the Domain Name System server with the hostname of your local hosts. In this case, when any other PC wants to ping the ‘dnstest.lab’ server, the router will resolve its domain name to the appropriate IP address.
DNS(config)#ip host dnstest.lab 172.16.0.2
Domain Name System Server Verification
From the Cisco router, I can ping the domain name.
DNS#ping dnstest.lab Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 172.16.0.2, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 2/3/4 ms
From PC1, I can ping the domain name.
C:\Users\PC1>ping dnstest.lab Pinging dnstest.lab [172.16.0.2] with 32 bytes of data: Reply from 172.16.0.2: bytes=32 time=9ms TTL=64 Reply from 172.16.0.2: bytes=32 time=2ms TTL=64 Reply from 172.16.0.2: bytes=32 time=2ms TTL=64 Reply from 172.16.0.2: bytes=32 time=3ms TTL=64 Ping statistics for 172.16.0.2: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 2, Maximum = 9ms, Average = 4ms
Also, I can access the web page from PC1.
Download our Free CCNA Study Guide PDF for complete notes on all the CCNA 200-301 exam topics in one book.
We recommend the Cisco CCNA Gold Bootcamp as your main CCNA training course. It’s the highest rated Cisco course online with an average rating of 4.8 from over 30,000 public reviews and is the gold standard in CCNA training: