Friday, April 12, 2013

Example to Set up DynDNS on a Cisco IOS Router



How to set up no-ip.com DDNS on your Cisco IOS router that actually works!

Normally we try to setup static IP addresses for our managed routers. However in this case the router was residential and in Singapore. Getting a static IP address was actually impossible.

I started the project by researching DDNS providers. Many of the DDNS providers that were free in the past are no-longer free. However no-ip.com still offers a free version of DDNS. The free version is under the section of their website for personal. At this time I could not find any statements on their site restricting the service to personal use. Here is a link to their site.

This procedure is easy to perform but due to lack of proper documentation and a lot of incorrect documentation, including that in the no-ip.com knowledgebase, it is more difficult than it should be.

This article assumes you have a basic knowledge of Cisco routers and know how to get into config mode and how to save your configuration.

There are three primary steps to setting up DDNS on a Cisco IOS router.
  1. Set up and confirm DNS resolution works.
  2. Set up a DDNS method to be called.
  3. Set up the external DHCP interface to call the DDNS update method.

Set up DNS resolution.
Confirm your router can ping something by name properly. A simple 'ping google.com' is an effective test. If it does not work you can setup you router DNS to use Google's public DNS servers with these two config lines:
  • ip dns server
  • ip name-server 8.8.8.8 8.8.4.4

Set up the DDNS method.
The method tells the router how to contact the DDNS provider, login and send the proper update command. It also controls the minimum and maximum time between DDNS updates. Do not set the maximum time too short. Many DDNS providers will lock you out if you update too frequently. I typically use one day but you need to check with your provider.

Create and name the DDNS update method.
  • ip ddns update method ddns-noip
Set the update mode to HTTP
  • HTTP

Create the ADD URL. The URL contains some special characters mainly the'?' that is problematic to enter because the router interprets it as a call for help. Use CTRL-V just before typing the '?' and the router will place it properly. Replace [username] and password with your no-ip credentials. You will need to enter your username as an email address including the '@' 
<h>&myip=<a> is a macro replaced by the router during the update with hostname and ip. i.e. hostname=myhostname.no-ip.org&myip=4.2.2.2'
  • add http://[username]:[Password]@dynupdate.no-ip.com/nic/update?hostname=<h>&myip=<a>
update minimum every 5 minutes maximum 1 day.
  • interval maximum 1 0 0 0
  • interval minimum 0 0 5 0

 Apply the update to the external DHCP interface.
Select the external interface and apply the update command to call the method you just created. For the Cisco 871 router used in this configuration it is Fast Ethernet 4. Replace it with your proper interface. For PPPoE it is likely interface Dialer 0.

Substitute your DDNS method name and the hostname to update at your DDNS provider with your specific details..
  • interface FastEthernet4
  • ip ddns update hostname [DDNS hostname]
  • ip ddns update ddns-noip

Debugging
Unfortunately I have not figured out a way to force a DDNS update NOW. What you can do is set your maximum update time short like 5 minutes. Turn on debugging with: debug ip ddns update.

You will get some very useful debug information. Make sure all the parameters are correct on the calls.

You may need to reload your router. I have round that changing the add command did not update properly after some changes until after a reload.

Sample Debugging Output for a working update.
*Aug 00 00:00:55.433 EDT: DYNDNSUPD: Adding DNS mapping for myhostname.no-ip.org <=>
111.111.111.111
*Aug 00 00:00:55.433 EDT: HTTPDNS: Update add called for myhostname.no-ip.org <=>
111.111.111.111
*Aug 00 00:00:55.433 EDT: HTTPDNSUPD: Session ID = 0x7
*Aug 00 00:00:55.433 EDT: HTTPDNSUPD: URL =
'http://myname@mydomain.com:mypassword@dynupdate.no-ip.com/nic/update?hostname=myhostname.no-ip.org&myip=111.111.111.111'
*Aug 00 00:00:55.433 EDT: HTTPDNSUPD: Sending request
*Aug 00 00:00:56.441 EDT: HTTPDNSUPD: Response for update myhostname.no-ip.org <=>
111.111.111.111
*Aug 00 00:00:56.441 EDT: HTTPDNSUPD: DATA START nochg 111.111.111.111
*Aug 00 00:00:56.445 EDT: HTTPDNSUPD: DATA END, Status is Response data recieved,
successfully
*Aug 00 00:00:56.445 EDT: HTTPDNSUPD: Call returned SUCCESS, update of
myhostname.no-ip.org <=> 111.111.111.111 succeeded
*Aug 00 00:00:56.445 EDT: DYNDNSUPD: Another update completed (outstanding=0, total=0)
*Aug 00 00:00:56.445 EDT: HTTPDNSUPD: Clearing all session 7 info
 

More Related DDNS Setup on a Cisco IOS Router

2 comments: