Local Network Server Obstacles
Locating an Hypertext Transfer Protocol (HTTP) server on a local network has some challenges.
The firewall in the local router restricts public access to the local network. You will need to allow remote HTTP clients on your local network.
A remote HTTP client will be able to access your webpage using the local network IP address, but you will probably want to provide a website name for convenience.
Also, your local network may not have a static IP address. If your internet service provider changes the IP address to your local network (if you have a dynamic IP address), how will a remote HTTP client access your webpage?
Solutions: Port Forwarding
Generally speaking, we want to prevent public Internet traffic from accessing our private local network. Nevertheless, you can allow Internet hosts to access your local network through a mechanism in the router called port forwarding.
Port forwarding allows Internet packets destined for a particular port on your local network to be forwarded to a specific local network IP address. Care must be used when allowing this access.
For our application, we need to configure the local router to forward incoming HTTP server packets to the local IP address assigned to the host running the HTTP server. Unauthorized access to the webpage can be prevented by requiring a username and password. You should also use some kind of encryption like SSL to prevent a packet sniffer from stealing your credentials.
Properly implemented and secure port forwarding is also referred to as a “firewall pinhole.”
Solutions: Local Server Website Name
Your web server is not required to have a website name, but it provides significant advantages.
Website names are easier to remember than IP addresses and if the IP address changes, DNS servers can be automatically updated to handle the change.
You can acquire domain names from domain name service companies like GoDaddy.com or DynDNS.com.
Solutions: Dynamic IP Address
Before we discuss how dynamic IP addresses affect the ability to access a local server, we first need to know what a dynamic IP address is.
Dynamic IP addresses are IP addresses that can change at any time. Internet service providers typically assign dynamic IP addresses to their customers. You can usually obtain a static IP address from an ISP, but they will charge you more for it.
Static IP addresses, as their name implies, are fixed and never change. Internet routers and servers typically use static IP addresses.
If your local router has been assigned a dynamic IP address, how does a remote host access your web server if the IP address changes?
If your remote HTTP client is using your website name instead of an IP address to access your HTTP server, all you need to do is update the DNS server with the new IP address. Some routers have this capability built into them. If yours doesn’t, you can have your embedded device periodically check its local network IP address and have it update its DNS server if it changes.
DynDNS and ZoneEdit are examples of two DNS service companies that can provide you with a domain name and the ability to update their DNS servers if your IP address changes.