Link to home
Start Free TrialLog in
Avatar of F-J-K
F-J-KFlag for Canada

asked on

Internal IP & External IP. How Client Knows to Which Server to Connect to Since External IP is the Same for All PC's in LAN

"your external ip address in given by your internet provider...one internet connection = one external ip address. Your internal ip's are different because each computer is assigned an address by your router/modem dhcp. Your router/modem knows what computer sent request for info and when received back it knows what internal ip to send it to. All packets are tagged so they are routed correctly in the internal lan."

Question:

Lets say i have a simple echo server in a pc behind a router. I made this server listens on port 4532. Assume server resides in 32.223.133.88 - external IP.

Now, i run a client in a completely different LAN. This client connects to 32.223.133.88/4532 ....

Assuming the router which produced 32.223.133.88 external IP has 50 PC's. All these 50 PC's carries same external IP Address.

How come my client knows on which pc to connect since there are 50 PC's and there maybe 20 PC's which listens on port 4532. Every PC of these 20, listens on 4532 for its own purpose in doing different functionality.

Note: lets say my client wants to connect to PC no. 9 to receive some data from the server.exe in PC no. 9 .....

I find it confusing as i do not find away to connect to the PC i'm aiming for since all external IP are same...

I hope you get my question...

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Darius Ghassem
Darius Ghassem
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of F-J-K

ASKER

thanks
Avatar of F-J-K

ASKER

Ops, i got a question!

What if more than one PC uses port 4532?

Assume i forwarded port 4532 to private IP 192.168.0.101
and i did port forwarding on port 4532 to private IP 192.168.0.105
Assume the calling client wants to connect to 192.168.0.101, but as you know client relies on my external IP only...

How come my router will know which PC the calling client wants to connect to?!
You could also ask the same question regarding how different applications on a particular computer get their packets from the outside world.  What if you have Internet Explorer and Firefox running at the same time?  Somehow it all gets worked out.

"ports numbers" are an extension to the IP address - that's a handy way to think about it.  They aren't physical ports.  
An analogy is the Post Office and the Post Office Boxes.  The Post Office is a "physical port" and the Post Office Box numbers are extensions that allow internal stuff to happen.  Not a great analogy perhaps but I hope you get the idea.

When a packet leaves a computer on the LAN, it has a port number for the specific application that sends the packet and expects a response.  Then, when the packet arrives at the router, the router adds a port address that identifies the particular computer.  Then, when packets return, they can be routed to the particular computer and to the particular application.

When you set up a specific port manually on a computer then that's the port for the application.  The port for the computer still has to get appended.