
Dynamic DNS Agent for TZO, v1.0
-------------------------------------------
Author:  Patrick J. Gleason
Date:  27-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.tzo.com".  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://www.checkip.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 TZO.com, for
which you must pay them a modest annual fee so they can eat and pay
their rent.  The Domain Name Server (DNS) at TZO 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 "www.checkip.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 "rh.tzo.com" that updates
the DNS record for its computer.

Any time that the program determines your IP address, it writes it to
a small ASCII text file named "LASTIP.TXT".  In a subsequent run, if
this file is found and read successfully, it may prevent a DNS record
update if it is found that your IP address is unchanged.  If this
file is not found, then the first IP address check is guaranteed to
result in a DNS record update.


Set Up Details:
----------------
A plain ASCII text file, named "TZOLKIN.INI" is used to tell this program
how to log on to "rh.tzo.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
        --------------------------------------------------------
        tzoname:        The "tzoname" parameter specifies the
                        host name you registered with TZO when
                        you acquired TZO service.  For example,
                        to update the DNS record for "www.idkcomp.com",
                        you would specify "www.idkcomp.com"
                        here, not just "www".  This name can be
                        up to 60 characters long.  THIS PARAMETER
                        IS REQUIRED.

        email:          The "email" parameter specifies your
                        user id for gaining access to the TZO
                        system.  This must exactly match the TZO
                        records for the host name ("tzoname")
                        that you are trying to update.  THIS
                        PARAMETER IS REQUIRED.

        tzokey:         The "tzokey" parameter specifies the serial
                        number to the DNS record identified by
                        "tzoname".  This key is e-mailed to you when you
                        create an account.  This acts as your
                        password.  THIS PARAMETER IS REQUIRED.

        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.
                        If you want to just do one IP address check
                        and update, then exit, perhaps as part of a
                        "CHRON" batch job, then specify 0 for the
                        period.

        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:

        TZOLKIN

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.

