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 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 192.168.78.128 -d 64.85.164.184 -j ACCEPT

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

iptables -t nat -A POSTROUTING -s 192.168.78.128 -o eth0 -j SNAT --to-source 64.85.164.184</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

1 Answer 1

I would suggest to set up the #2 server on VMWare to use NAT Mode (example of how to setup is here http://www.virtuatopia.com/index.php/VMware_Server_NAT_Configuration). After that setup the iptables with

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

You can test by pinging the gateway of 64.85.164.184 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

 
discard

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