sublime1's answer is not entirely accurate:
"Your IP address is assigned by your ISP (Internet Service
Provider) and will be the same for all the PCs attached to
your router and comprising your LAN (Local Area Network)."
This is not correct. If you have a router that sits between your
cable modem and the other PC's in your house, the router will be
assigned the unique IP Address by your ISP. The router uses something
called "Network Address Translation", NAT for short, to allow multiple
PC's in your house to access the internet hiding behind that one
unique IP address that your router uses.
The PC's inside your house, sitting behind your router, get a
"non-routable" IP address, either 192.168.x.x or 10.x.x.x., most of
the times its the 192.168 one. This is NAT, allowing multiple PC's on
a LAN to connect to the internet using one internet connection and one
IP address. These non-routable IP addresses cant go over the
internet, they are rejected by internet routers as unkown. So your
buddies cant connect to your server on your PC by typing in the
non-routable IP 192.168.0.5.. What they need is the unique IP
address on your router WAN plug, lets say 110.30.46.37. But you have
4 PC's on your LAN, so how do they get that one specific server?
They have to know the port to connect to. Its also why when you want
to www.whatismyip.com, you got the unique IP address sitting on your
WAN plug and not the non-routable ip address of 192.168.0.5 on the
specific PC you were using. Your router assigns these non-routable
addresses to your PC's when they are initially connected to the
router, and your router maintains a table of which PC is using wich
internal, non-routable IP address. When you went to whatismyip.com,
the router actually went to the web page, you PC kinda said something
like: "Hey router, go to this web page and give me whatever its
says", your router says " You got it, here is what I found"
When you go get a web page, like Googles home page, your computer
figures out Googles unique IP address, Googles is 72.14.207.99. When
your PC wants to get Googles web page it puts the port number for web
pages at the end of the ip address, example: 72.14.207.99:80 . AND it
gives Google a return address of 110.30.46.37:2235. Now thats your
unique IP address with a weird port number on it. All ports from
0-1024 are already assigned to specific purposes. 1024 - 65535 are
open for random use. When you wanted to make that initail contact
with Google and gets there web page, your PC had to go through port 80
to get to Google. Your PC is also telling Google to continue the
electronic conversation on port 2235, from that point on, until you
and Google are done communicating or time out, you will use port 2235
to exchange data. You dont see this because its hidden from the user
to make life simple, which is a good thing.
Now when you set up the server on your PC, how do your buddies access
it??? You go to your routers set up page. Like you said before,
when you entered your own unique IP address into a browser you got a
username password box, thats because your browser has a small web
server sitting on it so you can configure your router through a
browser. But you dont want anyone configuring your router, so you have
to log in and thats what the username password box is. Once you log
into your router go to the Port Forwarding page, this is where you can
set a specific port to send all traffic to a specific PC!!!!! That
page you were talking about before
"I went to the routers page and found a page with the following:
Port Range
Application Start End Protocol IP Address Enable
________ 0 to 0 TCP/UDP/Both 192...
"
Now, you should use a port number outside the assigned port range,
aka 0-1024. So when your buddies want to connect to you to play that
game, the ip address will have that port number at the end, example:
110.30.46.37:73489 . When your router gets those packets from your
buddies, it will check the port number at the end of the IP address,
the router will see port 73489, and it will know to send that packet
to you server PC.
NOW you can only assign one port number to one PC, that is the
limitation of your router. If you wanted to set up the same server on
all 4 PC's and have people connect to wichever PC has the least amount
of load on it, you would need a "Load Balancer", but thats a whole
different conversation.
Example of Port Forwarding Page
Port Range
Application Start End Protocol IP
Address Enable
Java Server 73489 to 73489 TCP/UDP 192.168.0.5
(checked on)
SO, when your router gets people connecting to it with port 73489,
your router will automatically forward those data packets to your PC
with the internal "non-routable" address of 192.168.0.5, on which your
server is running. |