Creating testbed networks of virtual machines, host Windows XP, guest Redhat Enterprise Linux
Contributed by Gary Griffin, 2007/03/17
Scenario
You have a host Windows XP system and a master Virtual image that is Redhat Enterprise Linux that you are regularly updating and want to create multiple instances and connect them in a private test network. An example would be a testbed MySQL Cluster which has a management node and two data nodes. Since the master image is regularly updated, we need a process for quickly cloning and creating a test environment.
- Clone the master Virtual image
vboxmanage clonevdi Master.vdi node1.vdi vboxmanage clonevdi Master.vdi node2.vdi vboxmanage clonevdi Master.vdi mgmt.vdi
- Attach the vdi's to the already created VMs.
vboxmanage modifyvm Node1 -hda node1.vdi vboxmanage modifyvm Node2 -hda node2.vdi vboxmanage modifyvm Mgmt -hda mgmt.vdi
- Create the network
Now reset the network for the new VMs to use an internal private network. This will allow the 3 guest VMs to communicate with each other, but not with the host. The intnet network type is not available from the GUI, and is reset by the GUI if any of the VM settings are changed. So this has to be performed from the command line. We choose to use a network name of 'testnet' just for convenience. It is an arbitrary name but must be consistent.
vboxmanage modifyvm Node1 -nic1 intnet vboxmanage modifyvm Node1 -intnet1 testnet vboxmanage modifyvm Node2 -nic1 intnet vboxmanage modifyvm Node2 -intnet1 testnet vboxmanage modifyvm Mgmt -nic1 intnet vboxmanage modifyvm Mgmt -intnet1 testnet
- Customization of individual VMs
Since these VMs will be in a private network, each has a fixed IP address. And they should use the host IP address as the gateway IP address. And example of the ifcfg.eth0 file where the host IP address is 192.168.1.101 and the guest IP address is 192.168.10.200 is:
DEVICE=eth0 ONBOOT=yes BOOTPROTO=none NETMASK=255.255.255.0 IPADDR=192.168.10.200 USERCTL=no PEERDNS=yes GATEWAY=192.168.1.101 TYPE=Ethernet IPV6INIT=no
Each guest should have a unique IP address.