
Dynamic DNS Agent for www.DynDNS.org, v1.2
-------------------------------------------
Author:  Patrick J. Gleason
Date:  7-Jan-2007
Project:  Bulletron Internet Operating System 12.0
Operating System:  OS/2 Warp 4.0 and later, eComStation
Compiler:  IBM VisualAge C++ 3.0
Phone: (315) 475-5598
Email: ora68@nehemiah.idkcomp.com
Web Site: http://www.idkcomp.com

This program lets you host a web server (or FTP, SMTP, etc.) without
having a static IP address; i.e., the IP address of your server is
established via DHCP.  Your server can be behind a firewall router
performing NAT (network address translation).  This program is
explicitly written to use the dynamic DNS service at
"http://www.dyndns.org", because this is the service that I am using.
You are welcome to write or phone me if you want a similar program for
some other dynamic DNS service.


How it Works:
--------------
Let's say you sign up with a service like Road Runner, and have a cable
modem that provides you with exactly one IP address.  To this, you
connect an inexpensive firewall router, like a Linksys BEFSR41.  The
firewall router lets you connecct a bunch of PCs to the Internet by
providing local IP addresses of the form "192.168.1.x".  The firewall
router lets all of the PCs on your LAN (local network) communicate with
each other by assigning them IP addresses like "192.168.1.101",
"192.168.1.102", etc.  It also routes any traffic not for your LAN to
the cable modem, which has an IP address that is unique to the entire
world.

For this example, suppose that the cable modem has the IP address,
"69.202.128.79", which is unique to the entire world, but could change
at any minute at the whim of the ISP.  On your LAN, you use a web
browser with an IP address of "192.168.1.103" (assigned by your router)
to access a web server outside the LAN.  Your firewall router translates
your PC's internet address to "69.202.128.79", port 80.  The remote web
server sends packets back to your PC using an IP address like
"69.202.128.79" port 1053.  Your firewall router translates
"69.202.128.79" port 1053 to "192.168.1.103" port 1053 and you are
surfing the web.  Your firewall router maintains an internal table that
it uses to route packets coming back from remote server(s) to the right
PCs inside your LAN, based on the port numbers.

Now, suppose you want to run a web server on your LAN that the whole
world can see.  On your LAN, your firewall router has assigned the IP
address "192.168.1.95" to the PC hosting your web site.  Using manual
setup for your firewall router, you tell it that any incoming connection
requests for port 80 should be routed to "192.168.1.95".  You can only
have one web server on your LAN that the outside world can see, but
heck, at least one is better than zero.

This program accesses a web site at "http://checkip.dyndns.org", which
sends back a small web page displaying the IP address of the host that
connected to it.  You can try this with Firefox (or other web browser)
and see what your IP address looks like to the world outside your LAN;
that is, beyond any proxies, routers, firewalls and NAT.  This program
does exactly that, at periodic intervals, to determine yow to set up
your DNS records.  Your master DNS records are hosted by DynDNS.org, for
which you must pay them a modest annual fee so they can eat and pay
their rent.  The Domain Name Server (DNS) at DynDNS will propogate
updates to your domain name records to the entire world in a matter of
seconds, so you can rapidly effect changes if the IP address of your web
server ever changes.

You run this program on the same computer as your web server.
It spends most of its time "sleeping".  Periodically, it wakes up and
queries "checkip.dyndns.org".  If it finds that the IP address of the
computer where it is running has not changed, then it does nothing and
goes back to "sleep".  If it finds that the IP address has changed,
then it performs a transaction with "members.dyndns.com" that updates
the DNS record for its computer.


Set Up Details:
----------------
A plain ASCII text file, named "DYNDNS.INI" is used to tell this program
how to log on to "members.dyndns.com", which DNS record to update, and
how often to check for changes.  This configuration file defines ten
parameters, some of which are optional.  Blank lines and lines beginning
with a semicolon in the configurattion file are ignored as comments.
Each parameter line consists of a label, followed by a colon, then a
space, then a value.  The parameters are:

        Label           Value
        --------------------------------------------------------
        userid:         specifies the user id that you use to
                        log on to "www.dyndns.org", manually
                        update your DNS records, and pay your
                        money.  This parameter is required.

        password:       specifes the password that you use for
                        that user id.  This parameter is
                        required.

        system:         can be "dyndns", "statdns" or "custom".
                        This specifies the class of service that
                        you signed up for with DynDNS.  We use
                        "custom" because it allows us to have
                        multiple web servers (some are located
                        in other cities).  This parameter is
                        required.

        hostname:       specifies the DNS record to be updated.
                        For example, we update "www.idkcomp.com",
                        "isaac.idkcomp.com", "nehemiah.idkcomp.com"
                        and "moses.idkcomp.com".  What you specify
                        here depends on what you specified for
                        the "system:" parameter and how you set up
                        your domain name records at DynDNS.org.
                        This parameter is required.

        wildcard:       can be "ON", "OFF" or "NOCHG".  "ON" means
                        that all host names in your domain map to
                        this one IP address, as when you have
                        different servers for different protocols
                        (HTTP, FTP, SMTP, etc.) on different hosts
                        on one LAN with port based NAT.  "OFF" means
                        that this IP address applies only to the
                        specifed "hostname:".  "NOCHG" means no
                        change.  This parameter is ignored for
                        "custom" domains.  If this parameter is
                        omitted for other types of domains, then the
                        default is "OFF".

        mx:             specifies the name of the preferred mail
                        exchanger for this host.  This parameter is
                        ignored for "custom" domains.  If this
                        parameter is omitted for other types of
                        domains, then all mail exchanger records
                        are cleared.

        backmx:         can be "YES", "NO" or "NOCHG".  "YES" specifies
                        that the host specified by "hostname" will
                        be set up as a backup mail exchanger for
                        "mx:".  This parameter is ignored for "custom"
                        domains.  If this parameter is omitted for
                        other types of domains, then the default is
                        "NO".

        offline:        can be "NO" or "YES".  If you put "YES"
                        here, then the DNS record for this server
                        will route traffic to a page saying that the
                        server is currently off-line for maintenance.
                        If this parameter is omitted, then the
                        default is "NO".

        period:         specifies the number of hours between
                        checking for IP address changes.  Policy at
                        DynDNS.org is that checking more frequently
                        than once every ten minutes is prohibited.
                        This program will not let you check
                        automatically more than once an hour.  Most
                        cable and DSL providers tend to leave your IP
                        address unchanged for years.  Dial-up connections
                        are pretty much guaranteed to give you a
                        different IP address every time you connect.

        verbose:        specifies the amount of information recorded
                        in the progam execution log:

                        0 = log IP checks and updates only

                        1 = also include all HTTP protocol details

                        2 = also include DEBUG style (hexadecimal
                            and ASCII) dump of all data sent and
                            received


Running the Program:
---------------------
You can execute this program from any OS/2 or eCS command line prompt
by entering:

        DYNDNS

There are no command line parameters.

You can call it from "STARTUP.CMD", put an object for it in your System
Startup folder, or whatever.

