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

Posted on 2008-11-08
Last Modified: 2012-05-05
"your external ip address in given by your internet 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."


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 - external IP.

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

Assuming the router which produced 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...

Question by:F-J-K
    LVL 59

    Accepted Solution

    In your router setup you need to setup port forwarding to forward all requests for the port to the local PC no 9. This is a setup that you must configure for the router to know where to forward the request too. If you don't the router doesn't no where to route the request to.
    LVL 1

    Author Closing Comment

    LVL 1

    Author Comment

    Ops, i got a question!

    What if more than one PC uses port 4532?

    Assume i forwarded port 4532 to private IP
    and i did port forwarding on port 4532 to private IP
    Assume the calling client wants to connect to, 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?!
    LVL 25

    Expert Comment

    by:Fred Marshall
    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Using in-flight Wi-Fi when you travel? Business travelers beware! In-flight Wi-Fi networks could rip the door right off your digital privacy portal. That’s no joke either, as it might also provide a convenient entrance for bad threat actors.
    The use of stolen credentials is a hot commodity this year allowing threat actors to move laterally within the network in order to avoid breach detection.
    The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
    The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now