If both of your home computers have the same public IP address, this means that these computers use NAT or Network Address Translation (strictly speaking, this is Port Address Translation or NAT Overload, but usually called just NAT).
This means that in order to initiate an external connection to any of your machines inside NAT, you must specify Port Forwarding on your router (usually your modem) so that you map a specific port on your public IP address to the IP address of your private IP addresses inside your home.
Let's say you have computers A and B in your house, like this:
Router / Modem 192.168.0.1 || ++=========++========++ || || Computer A Computer B 192.168.0.2 192.168.0.3
Now suppose you need computer A listening on TCP port 9000
(the ports can basically be TCP or UDP), you can redirect open port 9000
directly to port A 9000
:
Forward TCP/UDP on public port 9000 to private port 9000 on 192.168.0.2
To send a message to computer A, just send it to 1.2.3.4:9000
. But what if the other computer is only listening on port 9000
too? You also cannot assign the public port 9000
, because it is taken by computer A. You can do this:
Forward TCP/UDP on public port 9001 to private port 9000 on 192.168.0.3
Thus, computer B still receives messages on port 9000
, but they will need to be sent over the Internet at 1.2.3.4:9001
. Your NAT router automatically forwards the port as data packets enter (and leave!) Your home network.
In the end, the sender will need to configure the destination port to "talk" with different machines for NAT.
Hope this makes sense.
source share