Networking Virtual Machines
Networking in virtual machines uses the concept of a virtual network switch. A virtual network switch is constructed in software and runs on the host machine. The VMs connect to the network through the virtual switch. Depending on the configuration of the virtual switch, a VM can use an existing virtual network managed by the hypervisor, or can connect the host system's physical network interface.
|Not attached||In this mode the hypervisor reports to the guest OS that a network card is present, but that there is no connection. This is as if no Ethernet cable was plugged into the card.|
|Network Address Translation (NAT)||If all that is needed is to browse the Web, download files, and view email inside the guest, then this default mode should be sufficient.|
|Bridged networking||This is for more advanced networking needs, such as network simulations and running servers in a guest. When enabled the hypervisor connects to one of the installed network cards and exchanges network packets directly.|
|Internal networking||This can be used to create a different kind of software-based network which is visible to selected virtual machines, but not to applications running on the host or to the outside world.|
The virsh Shell
The virsh program is command line interface for managing virtual guest domains. The program can be used to create, pause, and shutdown domains. It can also be used to list current domains. Libvirt is a C toolkit that virsh is built on, and is used to interact with the virtualization capabilities of recent versions of Linux (and other OSes). It is free software available under the GNU Lesser General Public License. Virtualization of the Linux Operating System means the ability to run multiple instances of Operating Systems concurrently on a single hardware system where the basic resources are driven by a Linux instance.
Issuing the virsh command places the user in a shell with its own set of commands, some of which are shown below.
|help||Prints basic help information.|
|list||Lists all guests.|
|create||Creates a guest from an XML configuration file and starts the new guest.|
|start||Starts an inactive guest.|
|reboot||Reboots a guest.|
|restore||Restores a previously saved guest stored in a file.|
|resume||Resumes a paused guest.|
|save||Saves the present state of a guest to a file.|
|shutdown||Gracefully shuts down a guest.|
|suspend||Pauses a guest.|
Libvirt is a collection of software that provides a convenient way to manage virtual machines and other virtualization functionality, such as storage and network interface management. These software pieces include an API library, a daemon (libvirtd), and a command line utility (virsh).
An primary goal of libvirt is to provide a single way to manage multiple different virtualization providers/hypervisors. For example, the command 'virsh list --all' can be used to list the existing virtual machines for any supported hypervisor (KVM, Xen, VMWare ESX, etc.) No need to learn the hypervisor specific tools!
There is also a graphical interface for managing connectivity to virtual machines called Gnome Virtual Machine Manager. Most distributions of Linux can run this tool.