Vivek Viswanathan
Vivek Viswanathan Staff Engineer at Compass. Passionate about building software that pushes hardware to its limits!!

Hosting Website from your own PC

Hosting Website from your own PC

I was working on hosting a public website that contained a bunch of kitchen sink apps from my personal pc. This setup helps me in accessing a working instance of the apps from anywhere. This blog is about what was required in order to point a domain to a pc running at home. Here is the general flow within an wifi enabled home (using pioneer/airtel/act etc):

  • All devices are connected to the internal lan and each of the device is assigned a dynamic ip (e.g.:
  • The wifi router is part of a larger wan within the network provider's setup
  • After some hops, it is connected with a gateway that provides internet access. The hops can be identified by using the command: traceroute

Let us understand what are the shortcomings of the current setup before we point it to a domain that is purchased.

  1. To point to domain to be served by a public ip, we should make sure the wifi router's ip doesn't change
  2. We should also make sure the device/host serving the content for the website has a static ip
  3. Wifi router doesn't accept any connectivity initiated from public hosts

#1 is solved by using help from the service provider so that the wifi router is assigned a static public ip instead of a dynamic wan ip.

#2 is solved by changing the network setting on the required device to use a static lan ip. In linux/ubuntu/windows, this is done via the network setting tab. Change the ipv4 address from dynamic/dhcp to manual/static and assign an ip of the form 192.168.1.x, mask as and gateway as the wifi router's ip address. It is usually or (the same page used in accessing the setting page of the wifi router)

#3 is solved by changing the wifi router's setting. We have to configure it to forward the incoming request on certain port to an internal device. This is done using the "forwarding" configuration in the wifi router. Here is how to setup:

  • Service Port - The port that receives the connectivity from hosts from devices in internet (e.g.:80)
  • IP - The IP of the device in internal LAN that is serving the web requests (e.g:
  • Internal Port - The port on the LAN device that is serving the request (e.g.:8000)
  • Protocol - The protocol to be opened

Aside from this, we should also enable firewall & dos protection on the wifi router to prevent from attacks. Not to mention, the addition task of making sure the device within the lan serving the request should also be protected. This will be covered in later blogs, stay tuned.

comments powered by Disqus