Sunday, March 29, 2015

Cisco – Router as a DNS Server

As many didn’t know (me included) you can configure cisco router as DNS server.

A cisco router can:

  • Reply to requests for locally defined DNS entries.
  • Forward the request the public DNS servers (max 6)

In the cenario bellow we are going setup and test this.

Topology2

 

Configs

-- R1 --

interface FastEthernet0/0
description *** LAN ***
ip address 192.168.1.254 255.255.255.0
no shutdown

interface FastEthernet0/1
description *** WAN ***
ip address 200.0.0.2 255.255.255.252
no shutdown
 
ip route 0.0.0.0 0.0.0.0 200.0.0.1 name DefaultRoute
 
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Enable the router as a DNS server
! and domain lookup on the router
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ip dns server
ip domain-lookup

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Public name-servers, for the router to query
! the names it doesn't know
! Maximum 6x DNS servers
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ip name-server 4.2.2.5
ip name-server 4.2.2.6

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Local DNS Entries
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ip host PC1 192.168.1.1
ip host PC2 192.168.1.2
ip host PC3 192.168.1.3

The big secret here is the “ip dns server”, because the rest of the config you could have it to solve name locally on the router.

With the “ip dns server” you extend the router’s local name resolution, to the hosts on the network.

 

-- PC1 --

PCx

The PCs on my topology are actually routers so here is my config:

-- PC1 (Router) --
interface FastEthernet0/0
ip address 192.168.1.1 255.255.255.0
no shutdown

ip route 0.0.0.0 0.0.0.0 192.168.1.254 name GW

ip domain-lookup
ip name-server 192.168.1.254


-- PC2 (Router) --
interface FastEthernet0/0
ip address 192.168.1.2 255.255.255.0
no shutdown
 
ip route 0.0.0.0 0.0.0.0 192.168.1.254 name GW

ip domain-lookup
ip name-server 192.168.1.254


-- PC3 (Router) --
interface FastEthernet0/0
ip address 192.168.1.3 255.255.255.0
no shutdown

ip route 0.0.0.0 0.0.0.0 192.168.1.254 name GW

ip domain-lookup
ip name-server 192.168.1.254

 

Tests

-- Test the Local Entries for The PCs on the LAN --

PC1#ping PC2
Translating "PC2"...domain server (192.168.1.254) [OK]

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

PC1#ping PC3
Translating "PC3"...domain server (192.168.1.254) [OK]

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

-- Test Forwarding Request to Public DNS Servers--

PC1#ping www.google.com

Translating "www.google.com"...domain server (192.168.1.254) [OK]

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 216.58.208.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 52/69/84 ms

 

Related Links: