How-To serve website behind DHCP address.
I do not know the best forum to post the following how-to item.
Our only DSL provider in town gives DHCP IP addresses to home accounts. Static IPs are given to the much more expensive business accounts. Every home account gets a free web sit on their servers; a paltry useless 3MB site. You can spend more money to increase the size.
We wanted to serve large pictures and video to family and friends. We wanted to serve those large items from our own computers. How do you serve a website behind an unnamed DHCP address? The following works and if you want any of the code, send me a personal message.
The first and easy step was to set up my wife's iMac as a Web Server. It was assigned a static LAN IP address and our Linksys router forwards HTTP requests (port 80) to the iMac. If an individual knows the dynamic WAN address of the router, then they can see the site. Not very useful; no name and the IP address can change.
We put a very simple redirect HTML page on the ISP's supplied site. It redirects to our home site. If somebody goes to the named web site they would be redirected to my wife's iMac. Not very useful if our IP changes.
I wrote a unix script that retrieved the WAN IP address of the router (difficult but possible). If it changed then a newly constructed redirect HTML page is FTPed to the ISPs web site.
Using the freeware program Cronnix (sp?), the iMac every hour, on the hour, runs the script to automate the update of the named static website.
Getting the WAN IP address from our router required some programming. According to the folks at Linksys the only way to view the WAN IP from a LAN client is to go to the status web page using a browser. The code I wrote creates a network socket to the router. It does an HTML GET with Basic Authentication. An in-memory buffer is returned with the HTML. The HTML is then parsed to extract the WAN IP. If Linksys were to change the layout of the status page, the code would need to be rewritten.
If anybody else wants to do something similar and needs help, let me know.
Talk doesn't cook rice.