1

If am using Remote Desktop to login to a remote machine, how does the data for this connection get back into my machine if I don't open any ports on my router?

3 Answers 3

4

The same way any data gets back to your computer.

Your router is almost certainly running a stateful firewall and also NAT. This means it keeps track of connections you make through it.

RDP, like HTTP and many other protocls uses a stream socket. So if you make an RDP connection the RDP client will open a port on your client and then make a connection to the remote machine your connection might have details like this.

Source Address: 192.168.12.21
Source Port: 59034
Destination Address: 8.8.8.8
Destination Port: 3389

When initial packet passes through the firewall a entry is added to the state table that includes at least those details. If you are running NAT some additional information will be stored which will include what port the source port has been translated too. If the host you are attempting to connect to accepts your request it will respond to the source address/port that was in the packet. Your router will allow the incoming packet because it has an entry in the state table.

See also:

2
  • Ok, so I don't need to open a port if I am using Remote Desktop to connect to another computer, but the computer being connected to does need the port open?
    – CJ7
    Jun 25, 2010 at 5:34
  • Typically you need to open ports on a firewall for incoming connections only, where incoming is relative to the LAN
    – Zoredache
    Jun 25, 2010 at 5:43
1

It doesn't get through if you don't have any ports open, nor should anything else. You need port 3389 open to establish a remote desktop connection.

6
  • I don't have port 3389 open but it's working.
    – CJ7
    Jun 25, 2010 at 5:32
  • That depends on the firewall configuration; most consumer-grade router/firewalls allow everything out from the internal network.
    – Andrew
    Jun 25, 2010 at 5:33
  • @Andrew: but how does the data back in to my machine if I don't have port 3389 open?
    – CJ7
    Jun 25, 2010 at 5:34
  • @Craig That's what the NAT does.
    – Andrew
    Jun 25, 2010 at 5:44
  • Run a port scan and see for yourself. Jun 25, 2010 at 5:51
1

It doesn't.

But if your router uses NAT (or more specifically PAT, aka NAPT), a port is opened for you. Your router has a state table that keeps track of incoming ports, destination hosts, and destination ports; traffic on port X will be forwarded to port Y on host Z.

The connection without NAPT would be between port Y on host Z and port 3389 (for RDP) on the remote server; with NAPT it ends up between port X on the router and port 3389 on the remote server.


Whoops, I completely forgot about the remote host being in the state table...

2
  • How is it opening it for me? Which port is opened?
    – CJ7
    Jun 25, 2010 at 5:32
  • Port X on the router is opened and forwards packets to port Y on your internal host Z. Yes, I forgot that the source host is in the state table too.
    – Andrew
    Jun 25, 2010 at 5:46

You must log in to answer this question.

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