Click here to Skip to main content
15,883,883 members
Articles / Operating Systems / Windows
Tip/Trick

Convert Your Home Desktop to Webserver using IP-forwarding

Rate me:
Please Sign up or sign in to vote.
4.40/5 (5 votes)
11 May 2015CPOL4 min read 15.7K   15   6
This tip describes how to convert your personal laptop into a webserver available on world wide web

Introduction

Recently, when I was working on a personal web application being built on my laptop I wanted to have my friends test it over the internet.

I did not have a domain purchased yet and it was not ready as a production version. I did not want to buy a domain at testing phase of the site. After a few trial and errors, I figured out how I have my development laptop act as a webserver and allow external users to connect. 

This tip describes some simple steps which can be done to achieve this.

Using the Code

There is no coding needed for this - I will show here how to allow incoming traffic to your network end up routing the traffic to your local http server.

In my case, I was using a Microsoft IIS server, but this same trick can be applied for an application running on Java and using Apache server.

Considering you're using a Windows OS, first you need to figure out the IP address of your laptop. If you're inside a home network beside your ISP provided router, the router allocates different internal IPs to each of the latops connected to this network. These are internal IPs inside your network and not the IP on the world wide web.

First, you need to figure out what is your laptop's IP inside the network.

To get this, go to Windows command prompt and type ipconfig (or ipcofig|more - because the ipconfig output sometimes is too big). In the output of the command, you will see a line like this: 

Image 1

The IPv4 address is the address of your latop (considering your ISP is using IPv4 protocol), in this case it is 192.168.0.3.

The default gateway address (192.168.0.1) is the one of your home routers. The gateway has a very important role to play in allowing incoming traffic and routing those to your laptop, but we will discuss that shortly.

Remember, none of these addresses are public IP address, these are merely internal IP addresses inside your network.

Now, as my application was a .NET application, I needed to publish it and run it on my IIS webserver. If you are publishing a J2EE application, you would have deployed it on your Apache tomcat or websphere or weblogic. etc.

My web application was deployed on my local IIS server on Windows on port 9881 -

Image 2

See the binding details which says the application "onlineplat" is running on IP address 192.168.0.3 and listening on port 9881.

Now, my friends sitting outside of my network cannot connect to this application using the IP 192.168.0.3 - as this address is not visible to the outside world. How do I allow anyone else to connect to my applcation then? The trick is "IP-forwarding".

You have seen in the above screenshot where I did ipconfig and got the address of the dafault gateway or my router: 192.168.0.1.

This address is mostly the same for all routers for home network world wide. You need to now type this IP on your browser.

Your router will now prompt for an id/password. In most of the cases, the id is something like "admin" and the password is "password" if you have not changed it. If you did not set it or don't remember, you can check your router version and search on the internet for the deault password for the router.

If you had already set the password and forgot it, you can press the "reset" button of your router and then open this same url (http://192.168.0.1), where you can change the password.

Here is the screenshot from my router's home page -

Image 3

Different models of router will have different looking homepage, but all of them have a section "ip-forwarding". You can search on the internet for your router's ip-forwarding menu option. It generally is easy to find if you just search over the menu items.

The following screenshot shows the port forwarding rule I setup for my web-application:Image 4

What it means is, all incoming traffic to my home network on port 9881 will be forwarded to my laptop with address 192.168.0.3 which is the IP address (internal IP address within my home network) of my laptop running the application.

You also need to make sure that the port 9881 on your laptop is not blocking incoming traffic. To ensure this, type "firewall" in your windows run menu and setup an inbound rule to allow traffic on port 9881:

Image 5

Now, the last part is to figure out your gateway's exact IP address over the work wide web - which you can find out from sites like - https://www.whatismyip.com/ (this is not the only one). Basically, these sites poll your gateway and show your IP address.

For me, the IP address was 121.211.91.102

So now I told my friends to type http://121.211.91.102:9881/onlineplat  on their browser's URL and they were able to connect to my home made webserver over internet.

Of course, they were connecting using http and not https because I did not create my https settings - but that's part of a different discussion.

History

  • 11th May, 2015: Initial version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Australia Australia
Around 10 years of experience working in JSF and .NET both. I sometimes find time and love to write technical blogs.
Currently working out of Sydney for an assignment in ETL and Cloud Platforms.

If you like this post, you will probably be interested in checking similar posts here -
My personal website for blogs and more!

And here is My linkedin profile here

Comments and Discussions

 
SuggestionI would add Pin
Alexms12-May-15 9:44
Alexms12-May-15 9:44 
GeneralRe: I would add Pin
Shibasis Sengupta12-May-15 13:48
professionalShibasis Sengupta12-May-15 13:48 
Thanks Alexms.
Yes, generally for a dynamically assigned IP I always get a new IP every day or with every time I restart my router. But the idea was to present a home made solution without buying a DNS name.
GeneralRe: I would add Pin
Alexms13-May-15 2:53
Alexms13-May-15 2:53 
GeneralRe: I would add Pin
Shibasis Sengupta13-May-15 14:06
professionalShibasis Sengupta13-May-15 14:06 
QuestionReg : Information Pin
Abhishek RV11-May-15 21:25
professionalAbhishek RV11-May-15 21:25 
AnswerRe: Reg : Information Pin
Shibasis Sengupta11-May-15 23:46
professionalShibasis Sengupta11-May-15 23:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.