Purpose:
I only have one IP address assigned to my server and I have multiple virtual machines hosted on the server. In order to make those virtual machines access the Internet, I set up the VMWare network to be NAT. However, once a while the vmware NAT process runs 100% CPU and crashed the whole syste that I have to restart the machine. Replacing NAT with host-only virtual network is a work-around solution I found.
Procedure:
- Virtual server configuration:
- Run /usr/bin/vmware-config.pl, select host-only network instead of NAT
*note: if the Network Connections can not find any network interface (e.g. eth0), edit /etc/network/interfaces and comment out all except the following:
auto lo
iface lo inet loopback
- On vmware web interface, change network adapter to host-only.
- Turn on virtual server and config its ethernet adapter as following:
Static IP: 172.16.96.100
Primary DNS: 64.15.139.162
Secondary DNS: 208.67.222.222
Gateway: 172.16.96.1*note: the subnetwork are different each time you run vmware-config.pl. Make it to whatever static IP address for iptable NAT rules
- Run /usr/bin/vmware-config.pl, select host-only network instead of NAT
- Iptables rules
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp — anywhere anywhere tcp dpt:www
ACCEPT tcp — anywhere anywhere tcp dpt:ssh
ACCEPT tcp — anywhere anywhere tcp dpt:2222
ACCEPT tcp — anywhere anywhere tcp dpt:https
ACCEPT tcp — anywhere anywhere tcp dpt:8222
ACCEPT tcp — anywhere anywhere tcp dpt:8333
ACCEPT tcp — anywhere anywhere tcp dpt:902
ACCEPT tcp — anywhere anywhere tcp dpt:smtp
DROP all — anywhere anywhere
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
- Modify /etc/fstab to the new base virtual adapter IP address.
- Modify /etc/samba/smb.conf to recoganize the new virtual adapter vmnet1
- To fix SSH login slow problem edit /etc/ssh/sshd_config and add a line “UseDNS no”