On a routine basis, I come across many questions on forums related to people wanting to know how to host a web server on their private network. While there is quite a bit of detail in successfully setting up and maintaining the infrastructure needed to host a website, this summary should serve as a high level overview of the steps needed to complete this process.
The first step is to establish a domain name. Before you consider setting up your own DNS infrastructure, you may consider simply going with a domain name registrar that includes DNS management with the purchase of the domain name.
For instance, GoDaddy is one that I particularly appreciate because of the low cost associated with domain name registration and the fact that they provide you with the ability to fully manage your DNS records. They have a service called Total DNS.
When your registrar provides you with this type of service, my recommendation is for you to use it (since you are already paying for it) rather than setting up your own DNS server(s). This way, you do not have to worry about the extra costs associated with maintaining DNS.
However, if you really want to set up the DNS infrastructure on your own, you can do that. Simply provide the registrar with your Public IP address(s) for your DNS server(s). Most registrars require you to provide two IPs. If you have only one, simply use the same IP twice. Again, I do not recommend this, but it is an option for you.
If you do not know your public IP address, you can visit whatismyip.com. You must make sure that your public IP address is static and will not change. If you currently have a dynamic IP assigned to you, contact your ISP and ask for a static one.
They may charge you a few more dollars per month, but it’s worth it. You simply can not manage your own DNS with a dynamic address. If you are only setting up a web server, a dynamic IP can be used if absolutely needed. I will describe that process later in this summary.
If you decided to host your own DNS server, you’ll need to set it up and configure it. Once you set up the DNS Server on your internal network (install the service, set up your zones, etc…), you will need to allow the DNS related traffic through your firewall/NAT device.
To do so, you will need to create a port forwarding rule for port 53, TCP/UDP (however, most traffic will be UDP) that will map the public IP address to your server’s private IP address. Once you have validated the network configuration, then you’ll need to create a forward lookup zone hosting for your domain name.
This zone will require NS records (the ones you provided to the registrar during the DNS delegation process), and host (A) records (for resolving the NS records) that point to IP addresses.
Your next step is to set up the web server. If you are using a Windows Server, install the IIS role and create a new website that will be used to store your web files. Once your website is ready for Internet users, proceed by creating the appropriate DNS records. If your domain name is corp.com, you should create a parent record (@), and a host record called “www” in the corp.com DNS zone both pointing to your public IP address.
If you do not have a domain name and have a dynamic IP address, you can get a free one from various sources. Two that I know of are dynDNS.com and No-IP.com. They provide services that will allow your dynamic IP to update the free domain name when your dynamic IP changes. If you are simply learning about websites this option works well. However, if you want to build a real production website, I do not recommend this option.
Just as you did in the previous step in regards to port forwarding, you will need to do the same for your website. Create a port forwarding rule for HTTP traffic, port 80 which will map the public IP to the server’s private IP address. You will need to do the same for port 443 if your site will be supporting HTTPS.
Alternatively to hosting these options on your network, you may simply consider hosting DNS and the Web Server with an ISP. In the example above for GoDaddy, they provide hosting options for as low as a few dollars per month, to hundreds of dollars depending on what you require.