I have came across a lot of members on the forum that didn't have a clear idea of what port forwarding is and what it does. So...Let's get started...
Your router is blocking outside traffic from coming inside the network for security reasons (Kind of, like, a firewall level), unless a PC on the network wants it.
Imagine a celebrity.His bodyguard won't let you in his house for no reason, but, if the celebrity had ordered pizza though and you were the delivery guy , the bodyguard would be happy to have get you in :). That's what the router's firewall is and that's where port forwarding comes in. Port forward lets you choose a port of the router that's going to be open the whole time (or for a specified amount of time, if the router's settings allow you to) and outside traffic would be always allowed through that port.
Now, again, imagine an airport. The outside traffic has reached the terminal from that specific port that you opened, but still needs to go to its target -the flight 192.168.1.6 (A computer in the network)-. The airplane has still a LOT of ports (doors) (65.535 to be specific) and it need to go to a certain port of that plane. Now, you have specified that the traffic from port number X will enter the plane from port Y. The outside traffic that had previously entered the terminal, happened to have entered through that port (Port X), thus it boards the plane from port Y. See?! Easy! :P (In sort terms, you Forward a port from the router to your PC/Phone/Smart Fridge e.t.c.)
1)The Port X cannot be a higher number from Port Y (CORRECT--> PortX=56 & PortY=58 , WRONG---> PortX=345 & PortY=3).
2)The Port X should be a number close to that of the Port Y (PortX=56, PortY=58).
3) Port X can be the same as Port Y
4) Ports n.80,8080,20,21,23,25 are usualy used by the webserver of your router, so try to avoid using those...
5) NO DUPLICATE ROUTER-SIDE PORTS! ex. Rule1(PortX goes to PortY) Rule2(PortX goes to PortE) but the opposite, Rule1(PortX goes to PortY) Rule2(PortB goes to PortY), can happen.
Now let's say you have a web server that runs on your computer on port 80. You can access the Server only from devices from inside the network because the router blocks outside traffic. You port-forward port number 60 on your router to port 80 on you PC. Now you can access your lovely Web Server from (public ip):60!!! :D
Now the technical part of port forwarding is quite tricky, because there are millions of routers out there with different configuration page layouts. Thus, sites like PortForward.com exist () that offer guides for almost any router out there! (WARNING!: You do not need to pay in order to see the guides! When that screen pops-up, click the "Close" button on the top-right corner)
P.S. Now remember, each device inside the network has the SAME public IP address but NOT the same local IP address , so, your router doesn't only block outside traffic for your security reasons but it also doesn't know to which device the outside traffic is heading.
Thanks for reading
Want to start making money as a white hat hacker? Jump-start your white-hat hacking career with our 2020 Premium Ethical Hacking Certification Training Bundle from the new Null Byte Shop and get over 60 hours of training from ethical hacking professionals.