KeyLimeTie Blog

Dynamic IP Address Emailer - No need to buy a Static IP Address! (VB.NET)

By Brian Pautsch – 2/18/2006 11:20:38 AM. Posted to Applications.

A few months ago, a business partner and I sold our eBay drop-off store. We opened it in July of 2004 and it was the first eBay drop-off store in the Chicagoland area (maybe all of IL). It was working out OK, but we realized it would never be a huge money maker. The new owner just opened a new location in Manhattan...check it out: http://www.yourauctionpros.com

When we had the store, we had Yahoo DSL. I believe they wanted $40 or $50 for a static IP Address. It wasn't that important we have one, but we wanted one. I developed software for the store that managed the eBay auctions (it talked to eBay via APIs), automated the image resixing, created templates, talked with PayPal (also via APIs), managed out customers, balanced out acounting, etc. Well the software was an ever evolving product which required me to log into the system and migrate new versions. A dynamic IP Address would not do as migrations usually occured during non-business hours.

Solution: IP Address Sender - A windows service that checks the IP Address in the router and emails it to desigated email addresses when it changes.

Download code - Windows version to test with
Download code - Windows Service

Application configuration settings
App.config: The app.config file contains all of the settings you need to make this work for a Linksys router. I have tested it with two models (WRT54G - Wireless-G Broadband Router and BEFCMU10 - Cable Modem with USB and Ethernet Connections). The key names are pretty self-explanatory, but here are a few of the important ones:
  • Interval - How often will the service check (in milliseconds)
  • EmailUserName and EmailPassword - For email authentication, if necessary
  • RouterPage - Page in router intranet site that has the IP Address listed
  • RouterUserName - Username for logging into router intranet site. Note: Linksys default is " ", not ""
  • RouterPassword - I believe the Linksys default is "admin"
  • RouterPatternStart - Regular expression pattern before the IP Address to match
  • RouterPatternEnd - Regular expression pattern after the IP Address to match
    The Start/End Patterns matches are needed since the router page may list multiple IP Addresses.

    Main class that does everything
    clsMain.vb: The code is well commented, but a few things are worth noting:
  • Line 115: WebRequest object is used to get the router's HTML
  • Line 117: Credentials are supplied since the router's intranet sites requires authentication
  • Line 124-128: A regular expression is used to find a match on the IP Address
  • Line 136: Saves the IP Address to a physical file at the install path
  • Line 142: If the IP Address has been updated, an email is sent
  • Line 166: The new IP Address is saved to the physical file

    A word on Windows Services...
    Also included in the download zip file are two batch files which make installing and uninstalling the Windows Service a breeze. Be sure to update the paths first! Also, when Windows Services are installed and started, the ApplicationName.exe.config settings are loaded into memory. Any changes to this file will not take effect unless the service is uninstalled and reinstalled.
  • Comments

    On 1/8/2010 Albert said:
    Hi ;Does this code resolve the need to have static IP address ? or is it only for email? I went to buy static IP and I need to pay $59 more a month is this a work around or should I go ahead and by it.

    On 4/22/2008 ip hong said:
    my friend this need service

    On 6/29/2006 anonymous said:
    Great app. thanks.

    Leave a Comment

    Name:
    Email:
    URL:
    Comment:
    Security Code:
    Type Security Code:

    Photos on Flickr

    More Photos »

    Search Blog


    Get Email Updates

    Like what you read here at KeyLimeTie? Sign up for our email list!

    Subscribe