# Cisco IOS Configure Router as DNS Server

#### Network Topology

[![image.png](https://bookstack.taylorhome.run/uploads/images/gallery/2022-12/scaled-1680-/Ldtimage.png)](https://bookstack.taylorhome.run/uploads/images/gallery/2022-12/Ldtimage.png)

To create this topology, I used GNS3 instead of Cisco Packet Tracer because Packet Tracer routers do not simulate the "ip dns server" command. In the above network Router0 is being configured as a DNS server. Through the configuration of Router0 I wanted to not only demonstrate the ability for the router to resolve local hosts on the network, but I also wanted to show how DNS resolution that Router0 was unable to do could be forwarded to a real DNS server (1.1.1.1) on the Internet. In this way Router0 has been configured to forward unknown requests to the Cloudflare and APNIC's DNS server at 1.1.1.1. I also decided to use a real Windows 2016 Server appliance in the topology. I could have just as easily used another VPCS QEMU device, but it gave me an opportunity to revisit GNS3 Windows appliances. Also, it is not the best practice to use a networking router as the DNS server, but it can be done as this shows.

#### Router0 Configuration Commands

Router0&gt;enable  
Router0#configure terminal  
Router0(config)# interface gigabitEthernet 0/0  
Router0(config-if)#ip address 192.168.10.1 255.255.255.0  
Router0(config-if)#no shutdown  
Router0(config-if)#interface gigabitEthernet 0/1  
Router0(config-if)#ip address 172.16.1.1 255.255.255.248  
Router0(config-if)#no shutdown  
Router0(config-if)#exit  
Router0(config)#ip dns server  
Router0(config)#ip domain-name local  
Router0(config)#ip name-server 1.1.1.1  
Router0(config)# ip host fileserver.local 192.168.10.2  
Router0(config)# ip host pc1.local 192.168.10.3  
Router0(config)# ip host pc2.local 192.168.10.4  
Router0(config)# ip host router0.local 192.168.10.1  
Router0(config)# ip host router1.local 172.16.1.2  
Router0(config)# ip host router2.local 172.16.2.1  
Router0(config)# ip default-network 192.168.2.0  
Router0(config)# router ospf 1  
Router0(config-router)# network 172.16.1.0 0.0.0.7 area 0  
Router0(config-router)# network 192.168.10.0 0.0.0.255 area 0

#### Router1 Configuration Commands

Router1&gt;enable  
Router1#configure terminal  
Router1(config)# interface gigabitEthernet 0/0  
Router1(config-if)#ip address 172.16.1.2 255.255.255.248  
Router1(config-if)#no shutdown  
Router1(config-if)#interface gigabitEthernet 0/1  
Router1(config-if)#ip address 172.16.2.2 255.255.255.248  
Router1(config-if)#no shutdown  
Router1(config-if)#exit  
Router1(config)#ip name-server 172.16.1.1  
Router1(config)# ip default-network 192.168.2.0  
Router1(config)# router ospf 1  
Router1(config-router)# network 172.16.1.0 0.0.0.7 area 0  
Router1(config-router)# network 172.16.2.0 0.0.0.7 area 0

#### Router2 Configuration Commands

Router2&gt;enable  
Router2#configure terminal  
Router2(config)# interface gigabitEthernet 0/0  
Router2(config-if)#ip address dhcp  
Router2(config-if)#no shutdown  
Router2(config-if)#ip nat outside  
Router2(config-if)#interface gigabitEthernet 0/1  
Router2(config-if)#ip address 172.16.2.1 255.255.255.248  
Router2(config-if)#no shutdown  
Router2(config-if)#ip nat inside  
Router2(config-if)#exit  
Router2(config)#ip nat inside source list 1 interface gigabitEthernet0/0 overload  
Router2(config)#access-list 1 permit any  
Router2(config)# router ospf 1  
Router2(config-router)# network 192.168.2.0 0.0.0.255 area 0  
Router2(config-router)# network 172.16.2.0 0.0.0.7 area 0

The configuration of nat on Router2 is so that the network can communicate to the connected network and then to the Internet through the GNS3 cloud object. I did this to demonstrate the DNS forwarder on Router0 to 1.1.1.1 Also, the IP address on gigabitEthernet 0/0 is set for DHCP as it is getting an address from my network DHCP server. You could also make this a static address if desired. If you do set a static IP address, remember to configure a gateway of last resort. The DHCP setting configures that for the interface automatically.

#### Check DNS (a few ping examples)

PC1&gt;ping fileserver.local

[![image.png](https://bookstack.taylorhome.run/uploads/images/gallery/2023-01/scaled-1680-/image.png)](https://bookstack.taylorhome.run/uploads/images/gallery/2023-01/image.png)

PC1&gt;ping router2.local

[![image.png](https://bookstack.taylorhome.run/uploads/images/gallery/2023-01/scaled-1680-/B9zimage.png)](https://bookstack.taylorhome.run/uploads/images/gallery/2023-01/B9zimage.png)

PC1&gt;ping www.google.com

[![image.png](https://bookstack.taylorhome.run/uploads/images/gallery/2023-01/scaled-1680-/NDUimage.png)](https://bookstack.taylorhome.run/uploads/images/gallery/2023-01/NDUimage.png)

Check the configured DNS Hosts on Router0

Router0#show hosts

[![image.png](https://bookstack.taylorhome.run/uploads/images/gallery/2023-01/scaled-1680-/30qimage.png)](https://bookstack.taylorhome.run/uploads/images/gallery/2023-01/30qimage.png)

#### GNS3 File

[net11 cisco router dns server.gns3](https://bookstack.taylorhome.run/attachments/6)