Allocating a public IP address to a virtual machine hosted on an address-less real computer

 

Emin Gabrielyan, Christian Lathion

2008-02-27

Switzernet

 

This doc describes how to replace in the network the real machine by the virtual machine (a guest virtual computer) hosted within that real machine. When we dispose only of one public IP address, and our priority is the virtual machine, we can transfer the IP address from the real host machine to the virtual machine, leaving the host machine without any public IP address. The host machine need its public IP address only during the installation of its OS, of the VM service, and the OS of in the VM environment.

 

In our example we used the non-commercial version of vmware (http://vmware.com/) program. With vmware you can run the virtual machine in a NAT mode and in a bridge mode. In the NAT mode, you have a virtual private network connecting the virtual machine with the real machine. In the bridge mode, both machines have IP addresses accessible from the LAN, assuming that you dispose of two valid IP addresses. For our task we use the bridge mode:

[http://www.commentcamarche.net/faq/sujet-3759-vmware-les-differents-types-de-reseau-vmware]

 

Below we describe the steps for taking the public address from the real machine and transferring it to the virtual machine. The described below steps are implemented with a host machine running the Debian OS and with a guest virtual machine running FreeBSD.

 

Step #1:

The real machine (running Debian) has the real and the only available public IP address. Assume that 192.168.1.14 is the public address:

 

Step #2:

On the real machine, we create an alias network interface with a private IP address 10.0.0.10 (for the moment no one can access this machine with that IP address).

 

Step #3:

We create a virtual machine in a bridge network mode with another private IP address 10.0.0.21:

 

From the real machine we must be able to access the virtual machine by its address 10.0.0.21. The virtual machine can access the real machine via its address 10.0.0.11.

 

Step #4:

We create an alias interface on the virtual machine:

We must be able to reach the virtual machine from the real machine on its both IP addresses 10.0.0.21 and 10.0.022.

 

Step #5:

Now, the most responsible step: we must move the IP address 192.168.1.14 from the real machine to the virtual machine. We log into the virtual machine, via its IP address 10.0.0.22. We change the IP address 10.0.0.21 of the network interface of the virtual machine to the public IP address 192.168.1.14. Simultaneously we must change IP address 192.168.1.14 of the real machine to 10.0.0.12.

 

Now it is the virtual machine which replies to requests addressed to IP 192.168.1.14. Connection with the real machine is lost. The real machine is not accessible anymore from the network. We can login into the real machine only by passing via the virtual machine. Once the new settings are saved in the network configuration files of both machines, the system will now boot with the public IP address being permanently allocated to the virtual machine.

 

The presented example is successfully tested on Debian è Vmware è FreeBSD.

Other virtual machine solutions:

Product

Google popularity

Virtualbox

2’240’000

Xen

989’000

Qemu

1’300’000

Vmware

22’900’000

 

 

*   *   *