2

I have a situation that can be described as bellow:

CentOS A: 11.22.33.44(eth0 - WAN network) --- 5.11.22.33 (ham0 - Hamachi)

Win32 B: 55.66.77.88 (WAN network) ---- 5.11.22.44 (hamachi)

I use iptables to forward port 80 from A to B, so that people can access web server of 5.11.22.44 from 11.22.33.44

iptables -t nat -A PREROUTING --dst 11.22.33.44 -i eth0 -p tcp --dport 80 -j DNAT --to-destination 5.11.22.33:80
iptables -t nat -A POSTROUTING -p tcp --dst 5.11.22.33 --dport 80 -j SNAT --to-source 11.22.33.44

But it did not.

If I change the forward target to an ip that not in hamachi network, but in the WAN network, in this example: 55.66.77.88. It works perfectly.

Please tell me which part that I'm wrong?

Kenny Rasschaert
  • 8,925
  • 3
  • 41
  • 58
Tho Nguyen
  • 21
  • 2

1 Answers1

0

I'm trying to do something similar and it's working fine.

Could you try to set these rules:

iptables -t nat -A PREROUTING --dst 11.22.33.44 -i eth0 -p tcp --dport 80 -j DNAT --to-destination 5.11.22.44:80

iptables -t nat -A POSTROUTING -p tcp --dst 5.11.22.44 --dport 80 -j SNAT --to-source 5.11.22.33
Wesley
  • 32,320
  • 9
  • 80
  • 116