Luke Roberts
Luke Roberts

Reputation: 108

Do I need to port forward for communication between two machines on the same network?

I'm planning on writing a relatively simple client-server socket program in Java, where the server will run on one machine and the client on another machine (both wired on the same network).

Link two computers with Socket in Java.
From the answer to the above question, I believe that I will need to port forward (not an issue as I know how), but this does, however, go against my intuition as I am under the impression that port forwarding would only be necessary if I needed to connect to a service/machine/whatever on my network from a remote machine (not on the network).

So my question is, do I need to port forward for communicating between two machines on a local network? If yes, why?

Upvotes: 2

Views: 2671

Answers (1)

Mark Rotteveel
Mark Rotteveel

Reputation: 108991

If the machines are in the same network, you don't need to configure port-forwarding. Even if the machines are in different networks, you don't need to configure port-forwarding, assuming those machines have routable IP addresses (and there is no firewall blocking that access).

Port-forwarding is only relevant when communicating to - for example - a home network that has a single IP address, where there are multiple machines on an internal network, and the local router that is visible to the internet needs to perform NAT (Network Address Translation) to map between the local network and the big bad internet. Port-forwarding makes sure that an internet visible port is forwarded to the IP address of a machine on the internal network.

What you do need to take into account is the possibility that local machine firewalls (e.g. Windows Defender) may block access without explicitly whitelisting the application and/or port.

Upvotes: 4

Related Questions