Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I use ESX4.1 (vmware vsphere4) and I have one Public IP (X.X.X.X) in vswif0 and (192.168.1.1) in vswif1 and 2 virtual machines with local IP (192.168.1.2) and (192.168.1.3)

I want to use iptables firewall to redirect all iconming traffic to x.x.x.x:80 to 192.168.1.2:8080 and x.x.x.x:3306 to 192.168.1.3:3308

Could any body help me!

Thank you

share|improve this question

1 Answer 1

You need the following iptables commands:

iptables -A PREROUTING -d x.x.x.x -p tcp --dport 80 -j DNAT --to-destination 192.168.1.2:8080
iptables -A PREROUTING -d x.x.x.x -p tcp --dport 3306 -j DNAT --to-destination 192.168.1.3:3308

You need to make sure IP forwarding is enabled and the traffic is allowed in filter table.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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