Cannot Forward IP and portnumber to another IP address

us flag

I am trying to forward the packets to another internal IP address in AWS. (Linux).

My scenario is Gateway(EC2)( and two internal IP address ( and (

The packet coming to to on 10009 from (all) to be forwarded to on 10010 port number.

iptables -t nat -A PREROUTING -p tcp -s --dport 10009 -j DNAT --to-destination

I tried pre-routing but seems not to be working

us flag

In order for this to work, you need to either:

  1. Configure routing in so that packets leaving from port 10010 are forwarded to

  2. Add a masquerade rule at, which replaces packet source address with An example would be iptables -t nat -A POSTROUTING --dport 10009 -j MASQUERADE

In both cases you need to make sure IP forwarding is enabled, that is cat /proc/sys/net/ipv4/ip_forward shows 1.


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.