Unable to forward with iptables

cn flag

How can I forward traffic from a specific port to another machine?

+-----------------+     +----------------------+      +------------------------+
|     client      |     |   intermediary       |      |  server                |
|     (windows)   |     |    (debian)          |      |  (Windows)             |
| (eno1)     |      |                        |
+-----------------+     | (ens6f3)-+------+- (port 3389)  |
                        +----------------------+      +------------------------+

In this test case, I am trying to RDP (TCP port 3389) from client to server. I'm trying to set up iptables rules on the intermediary, but I'm failing to do so:

$ sudo sysctl -a
net.ipv4.ip_forward = 0
net.ipv4.conf.all.forwarding = 0
net.ipv4.conf.eno1.forwarding = 0
net.ipv4.conf.ens6f3.forwarding = 0
$ sudo sysctl net.ipv4.conf.eno1.forwarding=1
$ sudo iptables -A PREROUTING -t nat -i eno1 -p tcp --dport 3389 -j DNAT --to
$ sudo iptables -A FORWARD -p tcp -d --dport 3389 -j ACCEPT
$ sudo iptables -t nat -L -n -v
Chain PREROUTING (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target  prot opt in    out   source           destination     
    0     0 DNAT    tcp  --  eno1  *     tcp dpt:3389 to

I am now trying to RDP from to I am expecting to log into, but I get no response from that port.

What am I doing wrong?

I've also tried:

$ sudo sysctl net.ipv4.ip_forward=1
$ sudo iptables -A FORWARD -i eno1 -o ens6f3 -p tcp --syn --dport 3389 -m conntrack --ctstate NEW -j ACCEPT 
$ sudo iptables -A FORWARD -i eno1 -o ens6f3 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
$ sudo iptables -A FORWARD -i ens6f3 -o en01 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
Marco Caberletti avatar
dk flag
`INPUT` and `OUTPUT` chains are allowing the traffic?
Stewart avatar
cn flag
`sudo ip tables -L INPUT` gives `Chain INPUT (policy ACCEPT)` with no further details. Similar output for `OUTPUT`.
Mathias Weidner avatar
jp flag
Does your server know that the route back to the client ( goes via

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.