• No results found

Routing Between Two Host-Only Networks

If you are setting up a complex test network using virtual machines, you might want to  have two independent host‐only networks with a router between them.

There are two basic approaches. In one, the router software runs on the host computer. 

In the other, the router software runs in its own virtual machine. In both cases, you need  two host‐only interfaces.

The examples described here outline the simplest case, with one virtual machine on  each of the host‐only networks. For more complex configurations, you can add more  virtual machines and host‐only networks as appropriate.

Setting Up the First Host-Only Interface

On Windows hosts, the first host‐only network is set up when you install VMware  Server. 

On Linux hosts, the first host‐only network is set up when you run the 

vmware-config.pl program after you install VMware Server, provided you agree 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 interface on a Windows host 1 Go to Host > Virtual Network Settings > Host Virtual Adapters.

2 Click Add new adapter.

3 Choose the virtual network on which you want to use the adapter and click OK.

4 Click Apply.

5 Click OK to close the Virtual Network Editor.

To set up the second host-only interface on a Linux host 1 As root (su -), run the VMware Server configuration program.

vmware-config.pl

CAUTION In order to configure VMware Server correctly, the 

vmware-config.pl configuration program requires all virtual  machines to be shut down. The program shuts down any running  virtual machines automatically.

2 Use the Wizard to modify your configuration. After asking about a NAT network,  the program asks:

Do you want to be able to use host-only networking in your virtual machines?

Answer yes.

The Wizard reports on host‐only networks that you have already set up on the host  or, if none is present, configures the first host‐only network.

3 The Wizard asks:

Do you wish to configure another host-only network?

Answer yes.

Repeat this step until you have as many host‐only networks as you want. Then  answer no.

4 Complete the Wizard. When it is finished, it restarts all services used by VMware  Server.

5 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. 

Setting Up the Virtual Machines

Now you have two host‐only network adapters on the host computer. Each is  connected to its own virtual switch (VMnet1 and VMnet2). You are ready to create and  configure your virtual machines and connect them to the appropriate virtual switches.

Virtual Machine 1 — Connected to the Default Host-Only Interface 1 Create the virtual machine or use an existing virtual machine.

2 Launch a VMware Server Console and open the virtual machine. 

3 Edit the configuration using the virtual machine settings editor (VM > Settings).

Select NIC, select Custom, and choose VMnet1 (Host‐only) (on a Windows host)  or /dev/vmnet1 (on a Linux host) from the drop‐down list on the right.

If no network adapter is shown in the list of devices, click Add, and use the Add  Hardware Wizard to add an adapter.

Virtual Machine 2 — Connected to the Newly Created Host-Only Interface 1 Create the virtual machine or use an existing virtual machine.

2 Launch a VMware Server Console and open the virtual machine. 

3 Edit the configuration using the virtual machine settings editor (VM > Settings).

Select NIC, select Custom, and choose VMnet2 (Host‐only) (on a Windows host)  or /dev/vmnet2 (on a Linux host) from the drop‐down list on the right.

If no network adapter is shown in the list of devices, click Add, and use the Add  Hardware Wizard to add an adapter.

If you plan to run the router software on your host computer, you can skip the next  section.

Virtual Machine 3 — Connected to Both Host-Only Interfaces

If you plan to run the router software on a virtual machine, set up a third virtual  machine for that purpose.

1 Create the virtual machine or use an existing virtual machine.

2 Launch a VMware Server Console and open the virtual machine. 

3 Edit the configuration using the virtual machine settings editor (VM > Settings).

Select the first network adapter in the list of devices, select Custom, and choose  VMnet1 (Host‐only) (on a Windows host) or /dev/vmnet1 (on a Linux host) from  the drop‐down list on the right. Select the second network adapter in the list of  devices, then select Custom, choose VMnet 2 (Host‐only) (on a Windows host) or  /dev/vmnet2 (on a Linux host) from the drop‐down list on the right.

If you need to add one or more network adapters, click Add, and use the Add  Hardware Wizard to add an adapter.

Now you need to configure the networking components on the host and in the virtual  machines. The recommended approach uses static IP addresses for all the virtual  machines.

1 Stop the VMnet DHCP server service.

Windows host: Choose Host > Virtual Network Settings > DHCP and click Stop  service.

Linux host: Stop the vmnet-dhcpd service.

killall -TERM vmnet-dhcpd

2 Install guest operating systems in each of the virtual machines.

3 Install the router software — on the host computer or in the third virtual machine,  depending on the approach you are using.

4 Configure networking in the first two virtual machines to use addresses on the  appropriate host‐only network. 

On Windows hosts, you can open a command prompt and run ipconfig /all to  see what IP addresses each host‐only network is using. 

On Linux hosts, you can open a terminal and run ifconfig to see what IP  addresses each host‐only network is using. 

5 If you are running the router on the host computer, assign default router addresses  based on the addresses of the host‐only adapters on the host computer. In the first 

the IP address for the host‐only adapter connected to VMnet1. In the second virtual  machine’s networking configuration, the default router address should be the IP  address for the host‐only adapter connected to VMnet2. 

If you are running the router software on the third virtual machine, set the default  router addresses in the first two virtual machines based on those used by the third  virtual machine. In the first virtual machine’s networking configuration, the  default router address should be the IP address for the third virtual machine’s  Ethernet adapter connected to VMnet1. In the second virtual machine’s 

networking configuration, the default router address should be the IP address for  the third virtual machine’s Ethernet adapter connected to VMnet2. 

At this point you should be able to ping the router machine from virtual machines one  and two. And if the router software is set up correctly, you should be able to 

communicate between the first and second virtual machines.

Using Virtual Ethernet Adapters in Promiscuous Mode on a