Click here to Skip to main content
14,209,828 members
Click here to Skip to main content
Posted 27 Oct 2010

Tagged as


13 bookmarked


Rate this:
4.50 (2 votes)
Please Sign up or sign in to vote.
4.50 (2 votes)
29 Oct 2010     CPOL    
To help people with dynamic domains keep their DNS entries pointing at their home computer and to check for lost connectivity


  • To help people with dynamic domains keep their DNS entries pointing at their home computer.
  • To check for lost connectivity


MonitorRouterIP monitors the dynamic IP address of your router. It is assigned to you by your Internet Service Provider (ISP) when you configure your router to use DHCP. If you have a static IP, this program is useless to you. When your ISP assigns your router a new IP, then MonitorRouterIP alerts you in a variety of ways. You select those ways as part of your configuration.

MonitorRouterIP is designed to be used by home / small office networks that have a router with a simple web based interface. One where you access it from a browser, via a URL something like:

I (the author) use this program to know when I must update my DNS name servers at GoDaddy so my domains reflect my new IP.

This program does not run continually in the background. It needs to be installed as a scheduled task. It should wake up at intervals (I use an hour) and check for changes. If it changes, the program will send (optional) alerts in the form of:

email messages (via smtp)

email messages (via your default email client)

sms messages

running a program

messages displayed on the monitor

The program has a relatively small footprint and does not use much in the way of resources. Normally, it just reads the History file to get the last-known IP address of the router. It then gets the current address and compares them. If they are the same, then the program exits. This may be repeated for weeks or months until one day your IP changes. At this point, the alerts are sent out and the history file is updated with a new last-known IP address. You will not see any more alerts until the router IP address changes again.


There is no auto-installation method. It has to be done manually. There is a pre-requisite that you have to have Microsoft .NET 3.5 Framework installed. You will already have this on Windows 7, Vista-SP2 and XP -SP3. You can get it here.

1. Copy Files

Copy the following files to any directory. (We will assume c:\utility for the sake of this documentation.)

  • MonitorRouterIP.exe
  • MonitorRouterIP.rft (this file)

2. Run the Program

Run the program for the first time. It will ask you if you want to create a Configuration file. Just say OK. This will also create a new History file.

3. Edit the Configuration File

You should automatically be put in an editor for the Configuration file. If not, then manually edit the file:


Don't expect to get everything right the first time. The Configuration file defines three types of data. The first is the <ping> information which is used to determine connectivity. This next is the <router> section which defines how to access the router's IP. Finally there are messages. These are in the <alerts> section.

<ping>url=""</ping> section

This section of the configuration file in concerned with checking your connection to the internet. You should supply the URL of a site you can always access. I suggest your ISP - like my example above. If that site isn't working, chances are your aren't either. Just ensure it does respond to a ping by opening a command window and issuing the command:


After the first run, MonitorRouterIP remembers the ping IP in the configuration file and uses that rather than the URL. It's quicker and will work even if there is a DHCP failure.

<router> section

This section of the configuration file is concerned with connecting to the router, navigating to a suitable URL and then extracting the WAN IP address from the router. So the first thing to do is go to your router's configuration web pages. In the browser, you navigate to an address such as:, or Here is a list of router manufacturers and default IP addresses, user names and passwords.

Then, you will be prompted for a user and password. These are what go in the <user> and <password> values. The user is likely to be 'admin'. So this gives us:



Then hunt around until you find a page with the WAN IP on it. This is the <url> in the configuration file. On my dlink router, it is...


Now find out which occurrence of the IP address you want on that page. On my status page, it first displays my local IP address (, then it shows the subnet mask ( and then it shows my WAN IP address. It is the third IP address on the page so I need:


So that's the router section for my D-Link 524. Yours will be different.


<alerts> Section

This deals with how the MonitorRouterIP informs you when the IP address changes, connectivity is lost or something goes wrong. There are a number of ways you can be informed and they are each in their own section:

  • <sms>

    Send a text message. This is under development. Do not use it.

  • <display>

    Put messages on your monitor

  • <edithistory>

    Bring up the IP history file on the monitor

  • <email>

    Send a message using your default email client

  • <smtp>

    Send emails via Hotmail, Gmail, your ISP's email, your own SMTP server

  • <run>

    Execute a program, batch file, PowerShell script, etc.

In each section, you will see an attribute (that's the official XML name for it) in the form:

<xxxx use="true">

If you set it to use="false", then this will disable that alert only.

If you have <alerts use="false">, then it will disable all alerts no matter what the individual alerts say about "use". The only time I use is during demos / presentations elsewhere where I am connected to another network, or when I connect to a neighbour's wireless router so I can see my site from 'the outside".

<display use="true" duration="300" />

This causes a message to appear on the monitor, one for each error it finds. The duration is how long the message will stay on the screen. 300 means 5 minutes. duration="0" means the messages will stay till you close them (or your PC) down.

The program continues to run while the messages are displayed. If you are running the MonitorRouterIP as a task, you may well decide to kill it if it runs for more than a certain time. See the section below called scheduling.

<email use="true" />></email>

This sends a message via your default email client such as Outlook, Window Live or Eudora. There is another way of sending messages using SMTP as shown below. So why have both? SMTP delivers messages then and there. If there is no Internet, then no messages are sent. They are not buffered. You email client takes message and saves them. It will deliver them when it can.

You are likely to get a message saying something like "A program is trying to send an email message on your behalf. Do you want to allow this?". You can normally change this in your client. In Windows Mail, this is on the Security tab of the Options window under the Tools menu. It is a checkbox saying "Warn me when other applications try to send mail as me." This will be addressed in the next release.

<edithistory use="true">

If the IP address changes, then the file (say) c:\utility\MonitorRouterIP.history.xml will be brought up on the screen, probably in an editor. This does not timeout. Its use is somewhat limited.

<smtp use="true">

This is how you send emails. It is a bit complicated, but if you already have your email client working, then it should be fairly painless. If you only use webmail, then it may be more like extracting teeth. The subsection under <smtp> defines how to connect to the email network and how to construct the email. Let's look at each one and compare it to your email client. So look at an email client account. In my example below, I use Windows Mail, but all mail clients are pretty similar and need exactly the same information.

You can have multiple <smtp> entries. I have a local SMTP server I also send to. One of the problems is that if your router loses connectivity, then it cannot send the emails. Note that if this program cannot send email alerts, then they just do not happen. They are not stored for later despatch.


This will be the same as your outgoing mail (SMTP) server in Windows mail.

(Aside: If you run an SMTP server, it can also be in the form <server></server>.


This is the 'who' it will come from. Your mail server may not permit you to put something other than your real email address. Pointless to do otherwise, really. In Windows Mail, this is your "E-mail address:" on the General tab.


This is the main addressee for the alert email. Make sure it is real:


You can also copy other addresses such as internal emails to administration, etc. You can have as many <cc> entries as you want.


This is the standard Reply Address on the General tab of Windows mail.

<subject>Problem / Change of IP for router (gmail)</subject>

This is standard subject for the email. If you do not specify this, a suitable subject will be generated.


The standard SMTP port is 25. If your ISP is also your email provider, it will likely be 25. For example, my ISP is Roger, my email address is and the port is 25.

However, if I try ro send mail to a different SMTP server on port 25, then Rogers will block it. This is common behaviour from ISP to stop spam originating from your address.

Most non-ISP email providers use one or more different ports. They can also be different if you are using a secure connection. (That means your messages get encrypted.) For example, Gmail uses port 578 with a secure connection.

I will try to get the port numbers for the main email providers, Gmail, Hotmail, Yahoo, etc. You can send them to me if you like.


You will normally see this on the advanced tab of your email client set up. Here is the time in seconds that ChekRouterIP will try to connect to your email provider. 60 should be more than adequate. If you cannot contact your provider in that time, then you probably have an error somewhere else in this <smtp> configuration. (e.g., port, secureconnection, authentication.)


Almost all email providers require you to provide authentication. (i.e., supply a user name and password). The only time this may not be true is in a small office where you run your own email server. In Windows Mail, it is equivalent to the checkbox:

My Server requires authentication

Currently this program only supports the same setting security for outgoing mail as the incoming mail. If that is a problem, then set yourself up a Gmail or Hotmail account which you can use.


This is a totally different user to the one in the <router> section. This is the username you need to connect to your email provider. Usually, it is your email address. This is true of Gmail, Hotmail, Rogers, etc. Some email providers lose the '@' bit:


Your password for the email provider. Once again, this is a totally different password to the one in the <router> section.


This is defined by your email client. It causes things to be encrypted. Some sites demand you use this. Some demand you don't. And for some, it is optional - but they use different ports to connect.

<run use="true" />explorer.exe /e,/separate,c:\utility</email>

This will execute the program you specified. Here we are opening Explorer in a new window pointing at out "c:\utility" directory.

You are likely to get a message saying something like "A program is trying to send an email message on your behalf. Do you want to allow this?". You can normally change this in your client. In Windows Mail this is on the Security tab of the Options window under the Tools menu. It is a checkbox saying "Warn me when other applications try to send mail as me." This will be addressed in the next release.


You will need to test your alerts. When you first run the program, it will create a history file and a configuration file. The configuration file will be wrong and you will then edit it. It may still be wrong but you need to test it.

Edit the MonitorRouterIP.History.xml file. In the section, <current> alter the IP address. When you re-run the program, it will fire the alerts as the Router WAN IP no longer matches what is in the history file. Keep on changing the configuration file till you get it right. You will have to re-edit the History file every time in order to fire the alerts.

After you have got it working, you can then add it as a scheduled task...


You will almost certainly want to schedule this program. (If you decide to use it, that is.)

Here are my recommendations for setting it up as a scheduled task in Vista. It is going to be the very similar for Windows 7 or XP-SP3.

  1. Run "Task Scheduler". Depending on your system it may be:
    • > Start> then type in Task Scheduler and press enter
    • > Start> Administrative Tools > Task Scheduler
  2. Menu > Action > Create Task

In the Create Task window that pops up:

General Tab

Name: MonitorRouterIP

Description: Watches the router for when it changes its WAN IP address. When that happens, it alerts the user.

Run whether the user is logged on or not = ticked:

Triggers Tab

Press "New..."

In the New Trigger window:

Begin the task: On a schedule
Delay task for up (Random delay): (ticked) = 1hour
Repeat task every: (ticked) = 1 hour for a duration of : = 1 Day
Stop task if it runs longer than: 30 Minutes
Enabled: (Ticked)

Actions tab

Press "New..."

In the New Action window

Action: Start a program Program/script: c:\utility\MonitorRouterIP.exe (i.e. wherever you put it)
Start in: c:\util.

Conditions tab

Nothing to do unless you want to specify that the network is available.

Settings tab

Allow task to be run on demand (ticked).

Press OK.

When it asks for User name and Password, enter your logon id and password. This information is not available to MonitorRouterIP. It is needed by the Task Scheduler to supply the credentials that the program will run under.

Good luck!


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Paul R Cotter
Software Developer (Senior) Consultant
Canada Canada
Anyone out there know of a C# contract in Toronto?

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web05 | 2.8.190617.3 | Last Updated 29 Oct 2010
Article Copyright 2010 by Paul R Cotter
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid