Cisco 1921 Router - NAT, DNS, DHCP, ACLs and NTP

Date
Updated
OS
Cisco IOS
Hardware
Cisco 1921 Router

This series of commands might help you configure a Cisco 1921 router for a SOHO environment where many office computers share one Internet connection.

The method I used involves PAT (Port Address Translation) or NAT Overload.

This guide assumes that interface g0/0 will be connected to the Internet (WAN) and g0/1 is on the LAN side.

This guide is by no means fully comprehensive but should enable you to configure the router from a reset.

Here is the software version of the router on which I ran these commands:

Cisco IOS Software, C1900 Software (C1900-UNIVERSALK9-M), Version 15.2(4)M8, RELEASE SOFTWARE (fc1)

 

Configuring Basic Parameters and Remote Access Using SSHv2

Here I connected a serial cable to the light blue ethernet console port on the back of the 1921 router and powered up the device.

--- System Configuration Dialog ---
Would you like to enter the initial configuration dialog? [yes/no]: no

(press enter after information scrolls up)

Router>
Router>enable
Router#conf t
Router(config)#no logging console
Router(config)#enable secret Passw0rd1
Router(config)#end
Router#exit
Router>enable
Password:
Router#>conf t
Router(config)#service password-encryption
Router(config)#no service config
Router(config)#line vty 0 4
Router(config-line)#login local
Router(config-line)#transport input ssh
Router(config-line)#exit
Router(config)#username ciscoadmin password Passw0rd2
Router(config)#ip domain name mylan.tld
Router(config)#hostname ciscorouter
ciscorouter(config)#crypto key generate rsa label ssh modulus 1024
The name for the keys will be: ssh

%The key modulus size is 1024 bits
% Generating 1024 bit RSA keys, keys will be non-exportable...
[OK] (elapsed time was 1 seconds)

ciscorouter(config)# exit
ciscorouter#copy running-config startup-config
Destination filename [startup-config]?
Building configuration...
[OK]
ciscorouter#

 

NOTE: If after the router interface addresses have been configured you have issues connecting to the LAN port via SSH, then you might want to try specifying the Ciphers in an ~/.ssh/config file as follows:
 

Host ciscorouter
HostName ciscorouter.mylan.tld
Ciphers 3des-cbc
User ciscoadmin
 

 

Configuring the WAN and LAN Interfaces

The following section assumes that the Internet (g0/0) connection receives DHCP from an ISP.

ciscorouter#conf t
ciscorouter(config)#int g0/0
ciscorouter(config-if)#ip address dhcp
ciscorouter(config-if)#ip nat outside
ciscorouter(config-if)#exit
ciscorouter(config)#int g0/1
ciscorouter(config-if)#ip address 192.168.0.1 255.255.255.0
ciscorouter(config-if)#ip nat inside
ciscorouter(config-if)#exit
ciscorouter(config)#access-list 101 permit ip any any
ciscorouter(config)#ip nat inside source list 101 int g0/0 overload
ciscorouter(config)#exit
ciscorouter#copy running-config startup-config
Destination filename [startup-config]?
Building configuration...
[OK]
ciscorouter#reload reason test1
 

(confirm)

 

Hopefully now (after the device reboots) you can use SSH to connect to the LAN port of the router.

 

Configuring DNS, DHCP, Access Lists and NTP

 

DNS

ciscorouter>enable
Password:
ciscorouter#>conf t
ciscorouter(config)#ip dns server
ciscorouter(config)#ip domain name mylan.tld
ciscorouter(config)#ip domain lookup
ciscorouter(config)#ip dns primary 0.168.192.in-addr.arpa soa 192.168.0.1 hostmaster.mylan.tld
ciscorouter(config)#ip dns primary mylan.tld soa 192.168.0.1 hostmaster.mylan.tld
ciscorouter(config)#ip host mylan.tld ns ciscorouter.mylan.tld
ciscorouter(config)#ip host ciscorouter.mylan.tld 192.168.0.1
ciscorouter(config)#ip host server.mylan.tld 192.168.0.5
 

(continue as required)

ciscorouter(config)#ip dns view default
ciscorouter(cfg-dns-view)#dns forwarding
ciscorouter(cfg-dns-view)#dns forwarder 208.67.220.220
ciscorouter(cfg-dns-view)#dns forwarder 208.67.222.222
ciscorouter(cfg-dns-view)#domain name-server 192.168.0.1
ciscorouter(config)#exit
ciscorouter#show ip dns view default
DNS View default parameters:
Logging is off
DNS Resolver settings:
Domain lookup is enabled
Default domain name:
mylan.tld
Domain search list:
Lookup timeout:
1 seconds
Lookup retries:0
Domain name-servers:
192.168.0.1
DNS Server settings:
Forwarding of queries is enabled
Forwarder timeout: 3 seconds
Forwarder retries: 2
Forwarder addresses:
208.67.220.220
208.67.222.222
ciscorouter#copy running-config startup-config
Destination filename [startup-config]?
Building configuration...
[OK]
ciscorouter#  

 

DHCP

ciscorouter#conf t
ciscorouter(config)#service dhcp
ciscorouter(config)#ip dhcp pool MYLAN
ciscorouter(dhcp-config)#network 192.168.0.0 255.255.255.0
ciscorouter(dhcp-config)#default-router 192.168.0.1
ciscorouter(dhcp-config)#dns-server 192.168.0.1
ciscorouter(dhcp-config)#ip dhcp excluded-address 192.168.0.0 192.168.0.10
ciscorouter(dhcp-config)#end
ciscorouter#copy running-config startup-config
Destination filename [startup-config]?
Building configuration...
[OK]
ciscorouter#exit  

 

Access Lists

In order to protect services running on the interfaces from abuse, an access list can be assigned.

In this example I will consider the DNS and SSH services for the WAN (g0/0) interface.

Remember that at the end of any access list there is a default (invisible) implicit deny rule. This can be overridden as you will see below (rule 30) but it is worth bearing in mind.

ciscorouter# conf t
ciscorouter(config)#ip access-list ext 150
ciscorouter(config-ext-nacl)#20 deny tcp any any eq 22
ciscorouter(config-ext-nacl)#22 deny udp any any eq domain
ciscorouter(config-ext-nacl)#23 deny tcp any any eq domain
ciscorouter(config-ext-nacl)#30 permit ip any any
ciscorouter(config-ext-nacl)#exit
ciscorouter(config)#int g0/0
ciscorouter(config-if)#ip access-group 150 in
ciscorouter(config-if)#end
ciscorouter#copy running-config startup-config
Destination filename [startup-config]?
Building configuration...
[OK]
ciscorouter#exit  

 

NTP

To keep your router synchronised with the correct time, you might find it beneficial to configure the router to talk to an internal NTP server on the LAN interface. In this example, I'll use an internal NTP service which is on 192.168.0.12.

You could integrate the following lines into the previously shown 150 ACL to protect your router from bogus NTP queries. The ACL needs to be assigned to the external interface which in this case is g0/0.

In order to find the IP addresses of the NTP servers that I wanted to contact my internal NTP server, I first resolved as many of the servers' IP addresses from my chosen NTP pool that I could and then added them all into the access list below.

24 permit udp 192.168.0.12. 0.0.0.0.255 any eq ntp log
25 permit udp host xxx.xxx.xxx.xxx any eq ntp log
26 permit udp host xxx.xxx.xxx.xxx any eq ntp log
27 permit udp host xxx.xxx.xxx.xxx any eq ntp log
28 deny udp any any eq ntp log
29 deny tcp any any eq 123 log
 

 

ciscorouter#conf t
ciscorouter(config)#ntp server 192.168.0.12
ciscorouter(config)#int g0/1
ciscorouter(config-if)#ntp broadcast client
ciscorouter(config-if)#exit
ciscorouter(config)#exit
ciscorouter#copy running-config startup-config
Destination filename [startup-config]?
Building configuration...
[OK]
ciscorouter#exit  

 

Hopefully your network cup will runneth over when the following occurs.

# sh ntp status
Clock is synchronized, stratum 4, reference is xxx.xxx.xxx.xxx

 

This concludes the basic configuration guide for NAT, DNS, DHCP, Access Lists and NTP on a Cisco 1921 router.