Router port forwarding is used to allow the remote computers to connect to a specific service or computer on a Local Area Network. Now the question is why do we need it. And we will discuss all of these things one by one.
Use Cases :
- Suppose you are at the office and want to connect to your computer which is present in your house, the computer present at the house is connected to the WiFi of house which is a LAN(Local Area Network) one of the ways to connect to your house computer is port forward ssh(port 22) in your Router to your computers IP address and open ssh port on your computer. Now, who so ever will try to ssh to your public IP address will be forwarded to your computer present at your house.
- Suppose you want to host a website on your computer and you want everyone on the internet can access your website, this can be achieved by port forwarding. What you have to do is that port forward HTTP (port 80) or HTTPS(port 443) from your router to your computer on which your website is deployed. Hurray Knows anyone with your public IP address can access your website.
These are only two used cases that explain what is the need for Port forwarding, you can do much more like accessing the camera connecting to your LAN, accessing the printer connected on your LAN from anywhere in the world, you can also host a Minecraft server on your machine and invite friends to connect with it.
How To Implement Port Forwarding On Your Router :
Before starting with how to implement port forwarding two basic things are needed :
- Your Public IP address must be static because most of the normal internet connections have dynamic public addresses i.e the IP address changes after few hours or few days, so each time you have to connect to the machine present at your LAN you have to get your public IP address. Though for some users dynamic IP address will not be a big issue but in case you don’t want to know the IP again and again then you can ask your ISP to provide you a static IP.
- The 1st requirement was not that necessary the second requirement is very much necessary. You have to assign your machine(To whom you want to connect remotely) a static private IP address and this can be done very easily through your router and from your machine itself. This requirement is necessary because during port forwarding on the router we have to mention the IP address of the machine to which we want to forward the port so if the private IP address of the machine will be dynamic we have to configure port forwarding on the router again and again which is feasible.
Open the default gateway of your WiFi router usually the IP address of the default gateway for most of the routers is http://192.168.1.1 find your router’s gateway address and open it in your browser this will open the routers setting page login into this page.
After login search for NAT, Virtual Server, and after that enter the port or service you want to forward, after that enter the IP address of the machine to which you want to. forward that port(Please note that this is the general procedure for every router, for your router it may vary slightly)
Now you can easily access your machine with your public IP address remotely
Please note that if your machine(to whom you want to connect remotely) have a firewall installed then you have to manage that firewall to allow the remote requests
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.