[an error occurred while processing this directive]
Setting up Custom Host-Only networking to use VMware Workstation as a Virtual Router There are two ways to setup VMware Workstation to use Host-Only interfaces and a Linux Virtual Router. Actually there are probably 10-15, but two are probably the most popular. One way is to create Two Host-Only Interfaces. Create one Virtual Machine and configure it to access one of the Host-Only Interfaces then create another Virtual Machine configured to access the other Host-Only Interface. Then, you would install the Linux Router Software on the Host machine, and route the packets between the First Guest through the Host, its router, to the Second Guest. The Second option is to again create Two Host-Only Interfaces. You would also create Three Virtual Machines. The First Virtual Machine would be configured on the First Host-Only Interface, the Second Vitual Machine would be on the Second Host-Only Interface, and the Third Virtual Machine would be connected to Both Host-Only Interfaces. Then the first two Virtual Machines can be configured to route their packets to the Third Virtual machine which will have the Linux Router Software installed, and it will Route packets to the other Virtual Machine. To setup either of these scenarios, you will need to setup two Host-Only Interfaces. To do this, the first thing you need to do is install VMware Workstation. While running 'vmware-config.pl', make sure you install the Host-Only Interface. After you have finished installing and configuring, it will show you that the VMware Workstation services are started. Stop the VMware Workstation services /etc/rc.d/init.d/vmware stop Modify the /etc/rc.d/init.d/vmware script to add the second Host-Only interface. (Add the lines with + in front of them in the script file in the sections below).
# Start the host-only network user service
vmware_start_hostonly() {
local vHubNr="$1" # IN
local vHostIf="$2" # IN
local ifIp="$3" # IN
local ifMask="$4" # IN
local run_dhcpd="$5" # IN
local run_samba="$6" # IN
local ifNet
#
# Do a cursory check to see if the host-only network
# configuration is still ok. We do this so that mobile
# hosts don't get setup at install time and then moved to
# a new locale where the host-only network config is no
# longer valid.
#
# NB: This really needs to be done at power-on time when
# VM is configured to use host-only networking so that
# we aren't fooled by dynamic changes in the network.
#
# XXX ping takes 10 seconds to timeout if noone answers;
# that slows boot too much so we do this bit in the
# background.
#
if lookForHostOnlyNetwork "$ifIp"; then
echo 'Host-only networking disabled because '"$ifIp"
echo 'appears to be a real, physical, existing address.'
echo 'Please run "'"$vmware_bin_dir"'/vmware-config.pl" to'
echo 'modify your host-only network configuration.'
exit 1
fi
vmware_start_netifup "$vHostIf" "$vHubNr" || exit 1
# Configure the virtual host ethernet interface and define the private IP
# network
#
# . We provide the broadcast address explicitly because versions of ifconfig
# prior to 1.39 (1999-03-18) seem to miscompute it
# . 2.0.x kernels don't install a route when the interface is marked up, but
# 2.2.x kernel do. Since we want to see any errors from route we don't
# just discard messages from route, but instead check if the route got
# installed before manually adding one.
ifNet=`ipv4_subnet "$ifIp" "$ifMask"`
if ifconfig "$vHostIf" inet "$ifIp" netmask "$ifMask" \
broadcast `ipv4_broadcast "$ifIp" "$ifMask"` up \
&& noRoutePresent "$ifNet" "$vHostIf"; then
route add -net "$ifNet" netmask "$ifMask" "$vHostIf"
fi
if [ "$run_dhcpd" = 'yes' ]; then
vmware_start_dhcpd "$vHostIf" || exit 1
fi
if [ "$run_samba" = 'yes' ]; then
vmware_start_nmbd "$vHostIf" || exit 1
vmware_start_smbd "$vHostIf" || exit 1
fi
+# Enabling the vmnet2 interface
+ vHubNr=2 # IN
+ vHostIf=vmnet2 # IN
+ ifIp=192.168.225.1 # IN Whatever IP address you want for the vmnet2 interface
+ ifMask=255.255.255.0 # IN
+ vmware_start_netifup "$vHostIf" "$vHubNr" || exit 1
+ ifNet=`ipv4_subnet "$ifIp" "$ifMask"`
+ if ifconfig "$vHostIf" inet "$ifIp" netmask "$ifMask" \
+ broadcast `ipv4_broadcast "$ifIp" "$ifMask"` up \
+ && noRoutePresent "$ifNet" "$vHostIf"; then
+ route add -net "$ifNet" netmask "$ifMask" "$vHostIf"
+ fi
exit 0
}
**** And in the following ****
# Stop the host-only network user service
vmware_stop_hostonly() {
local vHostIf="$1" # IN
local ifIp="$2" # IN
local ifMask="$3" # IN
local ifNet
local ifPresent
# Terminate the private network
ifNet=`ipv4_subnet "$ifIp" "$ifMask"`
noRoutePresent "$ifNet" "$vHostIf" \
|| route del -net "$ifNet" netmask "$ifMask" || exit 1
# To test if the interface exists, we can not just look at the exitcode
# because old versions of ifconfig don't exit with 1 when invoked with a
# non-existing interface
ifPresent=`ifconfig "$vHostIf" 2>/dev/null`
if [ "$ifPresent" != '' ]; then
ifconfig "$vHostIf" down || exit 1
fi
vmware_stop_netifup "$vHostIf" || exit 1
+# Downing the vmnet2 interface
+ vHostIf=vmnet2 # IN
+ ifIp=192.168.225.1 # IN Whatever IP address you want for the vmnet2 interface
+ ifMask=255.255.255.0 # IN
+ ifPresent=`ifconfig "$vHostIf" 2>/dev/null`
+ if [ "$ifPresent" != '' ]; then
+ ifconfig "$vHostIf" down || exit 1
+ fi
+ vmware_stop_netifup "$vHostIf" || exit 1
exit 0
}
All this will do is create the Second Host-Only Interface.
Now you can start the vmware services again:/etc/rc.d/init.d/vmware start At this point the Status Indicators should all read OK. If so, running ifconfig should give you 4 interfaces (or more): eth0, lo, vmnet1 and vmnet2. The vmnetX interfaces may not show up right away, it could take a few seconds (say a max of 30). If you see these, then they should have different IP address on different subnets from one another. At this point you are ready to create the Virtual Machines. Create the First two Virtual Machines using the Configuration Wizard or however you want to create the machines (you can use existing Virtual Machines if you desire). Then, launch VMware Workstation and open the First Virtual Machine. Edit the Configuration using the Configuration Editor, and for the first Ethernet Adapter for Connection Type Click on Host-Only If the device doesn't show as installed on the Left Hand Panel (or the Install button is NOT greyed out), click install. Launch VMware Workstation and open the second Virtual Machine. Edit the Configuration using the Configuration Editor, and for the first Ethernet Adapter for Connection Type Click on Custom. For device, enter in /dev/vmnet2. If the device doesn't show as installed on the Left Hand Panel (or the Install button is NOT greyed out), click install. At this point, I would do a couple of things. First of all, I would stop the vmnet-dhcpd service so that the Virtual Machines won't get a DHCP address from the Host. You can use this if you want, or force the Virtual Machines to use Static IP addresses. Another thing I would do is install the Router software on the Host (as detailed in the first option above), or Setup a Third Virtual machine to hold the Routing Software. To setup the Third Virtual machine, create it as you did the first two. After it is created, edit the Configuration using the Configuration Editor, and for the first Ethernet Adapter for Connection Type Click on Host-Only If the device doesn't show as installed on the Left Hand Panel (or the Install button is NOT greyed out), click install. For the second Ethernet Adapter for Connection Type Click on Custom. For device, enter in /dev/vmnet2. If the device doesn't show as installed on the Left Hand Panel (or the Install button is NOT greyed out), click install. Boot the Third Virtual Machine and install the apropriate guest OS (Linux in the case). After you install the OS, you will notice that there are two AMD PCNet Family Adapters on this machine. The first connected to the vmnet1 interface, and the second connected to the vmnet2 interface. If you only installed one adapter with the Host OS install, install the second adapter and Routing Software now. If using Method One where the Host OS is going to hold the Router Software: At this point, boot up the other two Virtual Machines and Install the Guest OSes on them. Assign the proper IP addresses (I would recommend static at first). Assign the default router to be the Host vmnet1 IP address for the first Virtual Machine, and the default router to be the Host vmnet2 IP address for the second Virtual Machine. If using Method Two where a third Virtual Machine is going to hold the Router Software: At this point, boot up the other two Virtual Machines and install the guest operating systems. Assign the proper IP addresses (I would recommend static at first). Assign the default router to be the Third Virtual Machine's First IP address for the first Virtual Machine, and the default router to be the Third Virtual Machine's IP address for the second Virtual Machine. At this point you should be able to ping the Router machine from both Guests, and if the Router software is setup correctly, you should be able to communicate between the First and Second Virtual Machine. |