I am dealing with 3 machines (VMs):

  • A: (Client)
  • B: (Original Server)
  • C: (Redirect Server)

Now I want A to visit B and B to forward that to C.

I was able to achieve this by using:

iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination
iptables -t nat -A POSTROUTING -j MASQUERADE

But now I want to do this for one IP only (I.E) to when it tries to access I have already tried The answer here.

And yes, net.ipv4.ip_forward = 1 is also set.


Simply add something to match the ip you want the rule to match:

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.