2

I have a TCP client and server program that I made. My question is, when running the client and server on two separate machines that go through a different firewalled router over the internet, does it matter which router has ports forwarded? Ex. Can just the router used by the client machine have the correct TCP ports forwarded and the client server connection be established?

1
  • No: the client's router is irrelevant. Assuming (as is standard practice) that the client initiates the connection, then port forwarding on the client side plays no role whatsoever, for both requests and replies. In fact, the outgoing port is a high-number port randomly picked among free ports, it has no significance. It is only the server's router which must be configured to forward incoming connections on ports so and so to the correct machine running the requested service. Commented Sep 10, 2014 at 8:26

2 Answers 2

1

The ports need to be forwarded on the router for the receiving end of the connection. No matter what you do on the client end short of creating a direct network connection to the server's network, it will not affect the reachability of the server through it's firewall / router.

When you make a connection from the client to the server, the client sends the first packet out. If that packet cannot reach the server (which it cannot if the ports aren't forwarded), then the connection will timeout.

0

that can be done with ssh making a reverse ssh tunnel

using ssh -R

you run a whatever server and connect your ssh client to his ssh server with your ssh.exe -R, that creates a proxy port open on him which he connects to, and then that connection gets forwarded to the whatever server you are running. You have then avoided doing port forwarding on your router, even though you are running your whatever server which he is accessing.

two connections are made. The ssh connection, and the other connection tunneled through it, in this case going in the other direction.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .