|
I tried to figure out how to start VMWare on Linux so that the guest OS has transparent network access using NAT. Here is a way:
-
#!/bin/bash
-
#
-
# This scripts sets the forwarding rules for VMWare
-
#
-
# We assume that we have VMWare set up with NAT and
-
# have given the following IP addresses:
-
#
-
# Physical Network Adapter: PN=192.168.1.xxx
-
# VMWare Network Adapter: VN=192.168.2.xxx
-
#
-
# We do not know exactly which Interface and which
-
# IP address we have for the physical network - so
-
# we have to find these out first among eth0, eth1
-
#
-
-
PN=192.168.1
-
VN=192.168.2
-
-
IP=`ifconfig | grep -e "inet.\+:$PN.[^d]*\S" | sed "s/.*\($PN.*\?\) Bcast.*/\1/1"`
-
IF=`for i in eth0 eth1 ; do ifconfig $i | grep $IP >/dev/null && echo $i ; done`
-
-
sudo /sbin/iptables --flush
-
sudo /sbin/iptables -t nat --flush
-
sudo /sbin/iptables -t nat -P PREROUTING ACCEPT
-
sudo /sbin/iptables -t nat -P POSTROUTING ACCEPT
-
sudo /sbin/iptables -P FORWARD ACCEPT
-
sudo /sbin/iptables -P OUTPUT ACCEPT
-
sudo /sbin/iptables -P INPUT ACCEPT
-
sudo /sbin/iptables -t nat -A POSTROUTING -s $VN.0/24 -o $IF -j SNAT --to $IP
-
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward >/dev/null
-
-
/usr/bin/vmware
|