Contents

Setting Up Two Separate Host-Only Networks

For some configurations, you may need to set up more than one host-only network on the same host computer. You may, for example, want to have two virtual machines connected to one host-only network and at the same time have other virtual machines connected to another host-only network so the network traffic on each network is isolated from the other. Or you may want to test routing between two virtual networks. Or test a virtual machine with multiple network interface cards — without using any physical Ethernet adapters.

On Linux hosts, the first host-only network was set up when you ran the vmware-config.pl script after you installed VMware Workstation, provided you agreed to install host-only networking. If you did not agree to use host-only networking, you need to run the script again to set up host-only networking.

To set up the second host-only network, follow the steps outlined below for your host operating system.

  1. Stop the VMware Workstation services using this command in a terminal window:
    /etc/rc.d/init.d/vmware stop

  2. Use a text editor to modify the /etc/rc.d/init.d/vmware script to add the second host-only interface. Add the lines shown below with + in front of them that are in boldface. Do not type the + signs. A backslash (\) indicates that there should be no new line — the text appearing on the next line should continue, on the same line, at the point where the backslash appears. Do not type the backslash characters.

    # 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
    }

    This creates the second host-only interface.

  3. Start the VMware Workstation services again using this command in a terminal window:
    /etc/rc.d/init.d/vmware start

  4. Run ifconfig. You should see at least four network interfaces — eth0, lo, vmnet1 and vmnet2. If the VMnet interfaces do not show up immediately, wait for a minute, then run the command again. These four interfaces should have different IP address on separate subnets.

Configuring the Virtual Machines

Now you have two host-only interfaces (VMnet1 and VMnet2). You are ready to configure your virtual machines for one of the following scenarios:

Scenario 1 — Connect to the Default Host-Only Interface

  1. Create a new virtual machine.
  2. Select Settings > Configuration Editor from the Workstation window.
  3. Click the + sign to expand the Ethernet Adapters list, choose the first adapter, then from the Connection Type drop-down list on the right, choose Host-only. If the list of devices indicates the adapter is not installed, click Install.
  4. Click OK.

Scenario 2 — Connect to the Newly Created Host-Only Interface

  1. Create a new virtual machine.
  2. Select Settings > Configuration Editor from the Workstation window.
  3. Click the + sign to expand the Ethernet Adapters list, choose the first adapter, then from the Connection Type drop-down list on the right, choose Custom. In the VMnet field, type /dev/vmnet2. If the list of devices indicates the adapter is not installed, click Install.
  4. Click OK.

Scenario 3 — Connect to Two Host-Only Interfaces

  1. Create a new virtual machine.
  2. Select Settings > Configuration Editor from the Workstation window.
  3. Click the + sign to expand the Ethernet Adapters list, choose the first adapter, then from the Connection Type drop-down list on the right, choose Host-only.
  4. Choose the second adapter, then from the Connection Type drop-down list on the right, choose Custom. In the VMnet field, type /dev/vmnet2. If the list of devices indicates the adapter is not installed, click Install.
  5. Click OK.

At this point you can power on the virtual machine and install your guest operating system. In scenarios 1 and 2 you should see one AMD PCNet Family Adapter. In scenario 3 you should see two AMD PCNet Family Adapters within the guest operating system. Configure the virtual network adapters as you would configure physical adapters on a physical computer, giving each an IP address on the appropriate VMnet subnet.

To find out the network address for your virtual private network, you can run the following command from a shell window:

>ifconfig

Back to top

© 2002 VMware, Inc. All rights reserved.