Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a dedicated server running Linux CentOS 5.3 with 2 IP addresses. I've installed a virtual machine using VMware Server. The host and the guest have a host-only network. Now I want to map the 2nd IP address to the virtual machine so that it can run as a second dedicated server for me. Here is what I do:

modprobe iptable_nat

echo "1" > /proc/sys/net/ipv4/ip_forward

iptables -t filter -A FORWARD -s -d -j ACCEPT

iptables -t nat -A PREROUTING -d -i eth0 -j DNAT --to-destination

iptables -t nat -A POSTROUTING -s -o eth0 -j SNAT --to-source</p>

But it not working as intended. What is the matter?

share|improve this question
Any reason you can't set the guest up with a bridged network configuration? (VMWare Fusion offers this method, I assume VMWare Server does too) – epochwolf Apr 22 '09 at 3:59
the server provider assign 2 IP address on my host computer. And if I user bridged network, my virtual machine can not get IP address, neither via DHCP nor assigned manually – Thanh Tran Apr 22 '09 at 4:26

I would suggest to set up the #2 server on VMWare to use NAT Mode (example of how to setup is here After that setup the iptables with

iptables -A PREROUTING -t nat -i eth0 -p tcp -j DNAT --to-destination
iptables -A PREROUTING -t nat -o eth0 -p tcp -j SNAT --to-source

You can test by pinging the gateway of network from inside VMWare Server #2

share|improve this answer
Thanks, but look like this way all traffic will route to my #2 server and how about the host machine ? – Thanh Tran Apr 22 '09 at 5:10

Your Answer


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