Score:0

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)(9.19.22.22) and two internal IP address (10.0.0.5) and (10.0.0.6).

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

iptables -t nat -A PREROUTING -p tcp -s 17.16.0.99/32 --dport 10009 -j DNAT --to-destination 10.0.0.6:10010

I tried pre-routing but seems not to be working

Score:0
us flag

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

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

  2. Add a masquerade rule at 10.0.0.5, which replaces packet source address with 10.0.0.5. 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.

mangohost

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.