DNS on Cisco Routers

In this Cisco CCNA training tutorial, you will learn about the commands on how to configure a router to become a DNS Client. The reason you would do this is if you want the router itself to be able to resolve FQDN. Scroll down for the video and also text tutorial.

DNS on Cisco Routers Video Tutorial

YouTube video

Jon Roberts

Jon Roberts

Thank you for your courses I just passed the exam today on the first try. Thank you SO MUCH.

Jon Roberts

 

For example, you maybe want to ping LinuxA from the router, then you would need to set it as a DNS Client. You don't need to set the router as a DNS Client for DNS traffic to pass through it. This is only if you need the router itself to be able to resolve FQDNs to hostnames.

 

Router DNS Commands

 

Often when we're working on a router, we're always going to be working with IP addresses. If you did want it to be able to resolve hostnames, the commands to enter are:

 

  • ip domain-lookup: This command allows it to lookup at a DNS server
  • ip name-server <DNS server IP address>
  • ip domain-name <primary domain name>
  • ip domain-list <additional suffixes>: This command is used to lookup additional DNS suffixes

 

Router DNS Commands

 

If you wanted a router to be your DNS Server, then you would enter those same commands in the DNS Client configuration, plus the following commands:

 

  • ip dns server: This command configures it as a DNS server.
  • ip host <host name> <IP address of the host>: This command enters address records for everything that you want it to be able to resolve.

 

Now, you will not usually want a Cisco router to be a DNS Server. Usually, you would use an external Windows, or Unix or Linux server to do that.

 

In our example below, you can see I've got three routers, R1, R2, and R3. R1 has got IP address 10.10.10.1. R2 is 10.10.10.2, and it's also got an interface of 10.10.20.2. R3 is at 10.10.20.1.

 

I'm going to configure R3 as the DNS Server. I'm also going to configure entries for all three routers on there, so it will be able to resolve them. Then, we'll configure R1 as the DNS Client.

 

Router DNS Commands 1

 

Let's configure the DNS Server first, which is R3. I'll do a 'show ip interface brief' just to check the IP addresses right on there. 10.10.20.1 is going to be our DNS Server. In the global configuration mode, I'll enter the first command, ip domain-lookup, to enable it to use DNS.

 

Next up is the command ip name-server to configure where the DNS Server is going to be. It's going to be itself, which is at 10.10.20.1. Then, I'll configure the domain name with the command ip domain-name. For this example, I'll use flackbox.lab. Next, we’ll enter the command to make this the DNS server, ip dns server. Our commands would be:

 

ip domain-lookup

ip name-server 10.10.20.1

ip domain-name flackbox.lab

ip dns server

 

So, that's my basic DNS commands. Next up, I need to enter addresses for the host that I want to resolve. The first one is R1, which is at 10.10.10.1, then R2 at 10.10.10.2, and R3 at 10.10.20.1. The command for that is:

 

ip host R1 10.10.10.1

ip host R2 10.10.10.2

ip host R3 10.10.20.1

 

I'll also enter these as FQDNs as well. The commands would be:

 

ip host R1.flackbox.lab 10.10.10.1

ip host R2.flackbox.lab 10.10.10.2

ip host R3.flackbox.lab 10.10.20.1

 

That's all the config that I need for my DNS Server. Next up let's configure R1 to be a DNS Client. I'll go to R1’s global configuration mode and enter the command ip domain-lookup to allow it to use a DNS Server. Then, I’ll enter the command ip name-server to configure where the DNS Server is. That's on R3, which is at 10.10.20.1. Lastly, for the DNS suffix, I'll say ip domain-list flackbox.lab.

 

ip domain-lookup

ip name-server

ip domain-list flackbox.lab

 

Now, I'll use end command to drop back down to the enable prompt and let's see if I can resolve hostnames now on R1. So I will try pinging R3 by its hostname, ping R3, and see it's resolving it at the Domain Server at 10.10.20.1.

 

It then resolved that and the success rate was five out of five. That looks all good. Let's also try pinging R2, ping R2. So this will also be resolved by the DNS Server at 10.10.20.1, and it resolved that to 10.10.10.2. I was able to ping that too.

 

DNS on Cisco Routers Configuration Example

 

This configuration example is taken from my free ‘Cisco CCNA Lab Guide’ which includes over 350 pages of lab exercises and full instructions to set up the lab for free on your laptop.

 

Click here to download your free Cisco CCNA Lab Guide.

 

DNS on Cisco Routers Configuration Example

 

Note that routers cannot be DNS servers in Packet Tracer (it does not support the ‘ip dns server’ command) so we are using a Packet Tracer server device as the DNS server.

 

The host with IP address 10.10.10.10 has been configured as a DNS server and is able to resolve DNS requests for ‘R1’, ‘R2’, and ‘R3’.

A domain name is not in use.

 

  1. Configure R1, R2 and R3 to use 10.10.10.10 as their DNS server. You do not need to configure a domain-name or domain-list.

R1(config)#ip domain-lookup

R1(config)#ip name-server 10.10.10.10

 

R2(config)#ip domain-lookup

R2(config)#ip name-server 10.10.10.10

 

R3(config)#ip domain-lookup

R3(config)#ip name-server 10.10.10.10

 

2. Verify that you can ping R2 and R3 from R1 using their hostnames ‘R2’ and ‘R3’ (it may take some time for the DNS server to resolve the DNS request).

R1#ping R2

Translating "R2"...domain server (10.10.10.10)

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 10.10.10.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 0/0/1 ms

 

R1#ping R3

Translating "R3"...domain server (10.10.10.10)

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 10.10.20.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 0/0/1 ms

 

3. Verify that you can ping R1 and R2 from R3 using their hostnames ‘R1’ and ‘R2’.

R3#ping R1

Translating "R1"...domain server (10.10.10.10)

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 10.10.10.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 0/0/2 ms

 

R3#ping R2

Translating "R2"...domain server (10.10.10.10)

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 10.10.10.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 0/0/2 ms

 

Additional Resources

 

Configuring DNS on Cisco Routers: https://www.cisco.com/c/en/us/support/docs/ip/domain-name-system-dns/24182-reversedns.html

Chapter: Configuring DNS: https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/ipaddr_dns/configuration/15-mt/dns-15-mt-book/dns-config-dns.html

How to Configure a Cisco Router as a DNS Server?: https://study-ccna.com/configure-cisco-device-as-dns-server/

 

Want to practice Cisco CCNA technologies on your laptop? Download my complete 350-page Cisco CCNA Lab Guide for free.

 

Click Here to get my Cisco CCNA Gold Bootcamp, the highest rated CCNA course online with a 4.8 star rating from over 20,000 public reviews.

 

Libby Teofilo

Text by Libby Teofilo, Technical Writer at www.flackbox.com

With a mission to spread network awareness through writing, Libby consistently immerses herself into the unrelenting process of knowledge acquisition and dissemination. If not engrossed in technology, you might see her with a book in one hand and a coffee in the other.