2

I am dealing with 3 machines (VMs):

  • A: 172.20.10.1 (Client)
  • B: 172.20.10.2 (Original Server)
  • C: 172.20.10.5 (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 172.20.10.5:80
iptables -t nat -A POSTROUTING -j MASQUERADE

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

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

0

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

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

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