Installing a KVM virtualization system on CentOS. Installing CentOS in VirtualBox Installing KVM on our server


Task: install CentOS 7 to virtual machine Hyper-V second generation(Generation 2). First, go to the official CentOS website and download the iso image of the required version of the system.

1. Create a virtual machine

Let's create a new virtual machine in Hyper-V. Let's give it a name, for example VM-CentOS.

In the next step we will indicate that it will be second generation virtual machine(Generation 2).

Then “Configure Networking” - select Connection - LAN.

Now “Connect Virtual Hard Disk” - choose to create a new disk (Create a virtual hard disk) and set its size, name and location. For example, VM-CentOS.vhdx.

Next “Installation Options” - select installation of the system from the image (Install an OS from a bootable image file), which must be downloaded as an iso file from the official CentOS website, and indicate let to it (Image file iso).

The virtual machine has been created.

Right-click to go to the machine settings (Settings). In the Hardware block, select Firmware and uncheck the " Enable Secure Boot ".

If this is not done, the following error will appear at startup: " Boot Failed. EFI SCSI Device. Failed Secure Boot Verification."

2. Installing CentOS 7 to the created virtual machine

Now we start the car (Start). The CentOS installer welcome window will be displayed. If necessary, we will add Russian.

Now you can make preliminary settings.

Let's go to the "Keyboard" button. Here we can change the layout parameters if necessary (for example English language move up, change the layout keys, for example to the combination "Ctrl+Shift").

Click the "Select programs" button to select software, where you can specify which packages will be pre-installed. These parameters greatly depend on what you plan to use in the future. this system. If performance is important, you can select “Minimal installation”, and then “reinstall” all the necessary components.

When planning to use a CentOS machine for website hosting, you can set the “Standard web server” option and also add, for example, “PHP support”, “MariaDB client” and others.

If necessary GUI, then you can select "GNOME Environment" or "KDE Plasma Workspaces", add to it " Office suite" and so on.

Now let's set the network parameters. Go to “Network and host name”, set the host name and turn on the network using the top right radio button.

Now click “Start installation”.

While in background installation is in progress, we will set the necessary password for access.

Click "Root Password" and set the password for the administrator account.

If necessary, create a user.

Now we wait for the CentOS 7 installation to complete.

Click “Finish setup” and wait for the installation process to complete. After this, you will be prompted to reboot.

3. Checking the generation of the virtual machine

After the reboot, enter the previously created login password.

Note for those installing Linux system for the first time: the password is not displayed on the screen when entered.

Next, let’s check whether the created virtual machine is indeed a second generation machine (Generation 2). To do this, let's run on the hypervisor Windows PowerShell and run the following command (instead of "VM-CentOS" enter the name of your machine):

Get-vm VM-CentOS | fl name, generation

Make sure that Generation 2 is indicated. The installation is complete.

Monitoring HTTP requests IIS web server using Fiddler

Kooboo. Lesson 1: Introduction

Preparing the server

Checking for support from the processor:

cat /proc/cpuinfo | egrep "(vmx|svm)"

If the command does not return anything, the server does not support virtualization or it is disabled in the BIOS settings. KVM itself can be installed on such a server, but when we try to enter the hypervisor control command, we will receive the error “WARNING KVM acceleration not available, using "qemu"". In this case, you need to reboot the server, enter the BIOS, find support for virtualization technology (Intel VT or AMD-V) and enable it.

Let's create directories in which we will store everything related to virtualization (the ones offered by default are not convenient):

mkdir -p /kvm/(images,iso)

* catalog /kvm/images For virtual disks; /kvm/iso- for iso images.

Installation and launch

Installation is performed from the repository with the following command:

yum install qemu-kvm libvirt virt-install

* Where qemu-kvm— the hypervisor itself; libvirt— virtualization management library; virt-install— a utility for managing virtual machines.

Allow autostart:

systemctl enable libvirtd

Launch KVM:

systemctl start libvirtd

Network configuration

In this manual we will look at using a network bridge.

Setting up network bridge through remote connection, carefully check the entered data. If an error occurs, the connection will be terminated.

Install the package to work with bridge:

yum install bridge-utils

Let's look at the list of network interfaces and their settings:

In my example I had the following data:

1:lo: mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo

inet6::1/128 scope host
valid_lft forever preferred_lft forever
2: enp4s0f0: mtu 1500 qdisc pfifo_fast state UP qlen 1000

inet 192.168.1.24/24 brd 192.168.1.255 scope global enp4s0f0
valid_lft forever preferred_lft forever

valid_lft forever preferred_lft forever
3: enp5s5:

4: virbr0:


valid_lft forever preferred_lft forever
5: virbr0-nic:
link/ether 52:54:00:cd:86:98 brd ff:ff:ff:ff:ff:ff

* of these are important to us enp4s0f0- real network interface with a configured IP address 192.168.1.24 , through which the server connects to local network(we will make a bridge from it); 00:16:76:04:26:c6— mac address of the real ethernet adapter; virbr0- virtual network adapter.

Editing the settings of the real adapter:

vi /etc/sysconfig/network-scripts/ifcfg-enp4s0f0

Let's bring it to form:

ONBOOT=yes
BRIDGE=br0
TYPE=Ethernet
DEVICE=enp4s0f0
BOOTPROTO=none

Create an interface for the network bridge:

vi /etc/sysconfig/network-scripts/ifcfg-br0

DEVICE=br0
TYPE=Bridge
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.1.24
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=77.88.8.8

Restart the network service:

systemctl restart network

The network settings must change - in my case:

2: enp4s0f0: mtu 1500 qdisc pfifo_fast master br0 state UP qlen 1000
link/ether 00:16:76:04:26:c6 brd ff:ff:ff:ff:ff:ff
3: enp5s5: mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
link/ether 00:16:76:04:26:c7 brd ff:ff:ff:ff:ff:ff
4: virbr0: mtu 1500 qdisc noqueue state DOWN qlen 1000
link/ether 52:54:00:cd:86:98 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
5: virbr0-nic: mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000
link/ether 52:54:00:cd:86:98 brd ff:ff:ff:ff:ff:ff
6:br0: mtu 1500 qdisc noqueue state UP qlen 1000
link/ether 00:16:76:04:26:c6 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.24/24 brd 192.168.1.255 scope global br0
valid_lft forever preferred_lft forever
inet6 fe80::216:76ff:fe04:26c6/64 scope link
valid_lft forever preferred_lft forever

We insist on redirecting network traffic:

vi /etc/sysctl.d/99-sysctl.conf

net.ipv4.ip_forward=1

Apply the settings:

sysctl -p /etc/sysctl.d/99-sysctl.conf

Restart libvirtd:

systemctl restart libvirtd

Creating a virtual machine

Let's look at the available options for guest operating systems:

To create the first virtual machine, enter the following command:

virt-install -n FirstTest\
--noautoconsole\
--network=bridge:br0 \
--ram 1024 --arch=x86_64 \
--vcpus=1 --cpu host --check-cpu \
--disk path=/kvm/images/FirstTest-disk1.img,size=16 \
--cdrom /kvm/iso/CentOS-7-x86_64-Minimal-1611.iso \
--graphics vnc,listen=0.0.0.0,password=my_password \
--os-type linux --os-variant=rhel7 --boot cdrom,hd,menu=on

  • FirstTest - the name of the machine being created;
  • noautoconsole — does not automatically connect to the virtual machine console after creation;
  • network - network type (in our example, network bridge);
  • ram - volume random access memory, which will be highlighted;
  • vcpus — number of virtual processors;
  • disk - virtual disk: path — path to the disk; size — its volume;
  • cdrom - virtual drive with a system image;
  • graphics connection parameters to the virtual machine using the graphical console (in in this example use vnc); listen — at what address vnc requests are received (in our example, all); password — password for connecting using vnc;
  • os-variant — guest operating system (we received the entire list with the command osinfo-query os, in this example we install Rev Hat 7 / CentOS 7).

Allow autostart for the created VM:

virsh autostart FirstTest

Connecting to a virtual machine

To further install the operating system, download a VNC client to the administrator’s computer, for example, TightVNC and install it.

On the server, we look at which port the created machine listens to VNC on:

virsh vncdisplay FirstTest

in my case it was:

This means that you need to add 0 to 5900. If the result of the command is: 1 - 5900 + 1 = 5901 and so on.

Open the port on the firewall:

firewall-cmd --permanent --add-port=5900-5905/tcp

firewall-cmd --reload

* in this example, 6 tcp ports from 5900 before 5905 .

We launch the installed TightVNC Viewer, in the window that opens, enter the IP address of the KVM server and the port on which our VM is listening (in this example, 5900):

Click Connect. The program will ask for a password - enter the one you specified when creating the VM (in this example, my_password). We will connect to the virtual machine as if it had a monitor or remote KVM console connected to it.

Admin and the password that was created when executing the command engine-setup. After successful login, you can manage virtual machines through the web interface.

Continuing the games with organizing virtual Windows on a dedicated server, I decided to try out KVM, because until that moment there had always been enough VMware and VirtualBox products. And then on one of the forums I read some comrade’s angry tirade about the fact that only idiots install VirtualBox where they can install KVM.

Well, I decided to take a look. I must say that in my understanding, VIrtualBox is a little more tedious to install than KVM, but it is easier to manage and there are no hemorrhoids with setting up the grid, although it may be inferior in functionality. The same cannot be said about ESXi. But first things first.

I installed it as standard on CentOS 6.7, so we start with the system update:
# yum -y update

We look at whether the processor supports hardware virtualization, since KVM requires support for Intel VT or AMD-V for its operation
# egrep -i "vmx|svm" --color=always /proc/cpuinfo
the output must contain either vmx or svm

We look at the status of SELinux access control
#sestatus
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: enforcing
Mode from config file: enforcing
Policy version: 24
Policy from config file: targeted

theoretically, it can interfere with access to disks, so it must either be correctly configured to work with the image folder, or disabled, which is naturally easier for me - in the /etc/selinux/config file we change the value of the SELINUX parameter to disabled and reboot the machine
SELINUX=disabled

Importing GPG keys for packages
# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
We install all the mince: kvm itself, libvirt virtual machine management API, virtinst virtual machine creation tool and qemu-kvm hypervisor
# yum -y install kvm libvirt python-virtinst qemu-kvm

Launch libvirt and register the autoload module
# /etc/init.d/libvirtd start
# chkconfig libvirtd on

We check how KVM installed and started (there should be 0 errors in the output)
# virsh -c qemu:///system list
ID Name State
—————————————————-

We install a network bridge to connect guest machines to the external network and the terrible, terrible entornet
# yum install bridge-utils

We create a network bridge config similar to the network interface settings, but with a slight difference:
# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-br0

###### /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
TYPE=bridge
ONBOOT=yes
BOOTPROTO=none
NM_CONTROLLED=yes
IPADDR=SERVER_IP
PREFIX=24
GATEWAY=GW_IP
DNS1=8.8.8.8
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=”System br0″
##################
then we edit the settings of the main interface, commenting on the parameters BOOTPROTO, IPADDR, PREFIX, GATEWAY, DNS1 and registering the network bridge
###### /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
#BOOTPROTO=none
HWADDR=01:2e:32:ab:9f:1e
#IPADDR=SERVER_IP
#PREFIX=24
#GATEWAY=GW_IP
#DNS1=8.8.8.8
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=”System eth0″
BRIDGE=br0
##################

Now let’s restart the grid and see what happened - we should show 4 interfaces:
br0 with main IP
eth0 without IP
lo 127.0.0.1
virbr0 with the internal IP of the virtual router

We check the status of our network bridge:
# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.002215ab999d no eth0
virbr0 8000.52540052c0e1 yes virbr0-nic

theoretically, you can speed up the work of the network bridge by adding the following parameters to the /etc/sysctl.conf file:
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0

Now let's move on to creating a directory for storing images of virtual machines and dist iso images
# mkdir /usr/vm/iso
# mkdir /usr/vm/vm-images

By default, all machine images, disk images, etc. are stored in /var/lib/libvirt/, but I decided to show off and cut the disk in the best old-school traditions of partitioning, so take this into account when installing the server, or you will have to delete the original storage and link as to me, on /usr

# rm -Rf /var/lib/libvirt/images
# ln -s usr/vm/iso /var/lib/libvirt/images

After all this preparation, we are trying to create a virtual machine under Windows 7 with 2 virtual processors, 4Gb RAM, 30Gb HDD, storing the image in the /usr/vm/vm-images folder and the windows7.iso image that we downloaded earlier into the /usr/vm folder /iso

# virt-install --connect=qemu:///system -n win7 -r 4096 --vcpus=2 --disk path=/usr/vm/vm-images/win7.img,size=30 -c /usr /vm/iso/windows7.iso --vnc --noautoconsole --os-type windows --os-variant win7 --accelerate --network=bridge:br0 --hvm

If everything is fine, we will see the disk creation process. On this solemn note, you can move on to setting up the machine, and here lies the real ambush, because if you are working under Windows, then the options are either control via ming via putty-ssh, but this requires X Windows on the server side, or a completely incomprehensible virtual viewer tool, which I could not get to work. Therefore, all I could find was either this external service that allows you to connect your KVM to their admin panel; or install your own web admin based on Webmin Cloudmin GPL.

Here it should be noted that the grid initialization line –network=bridge:br0 will allow you to use public IP on a virtual machine, whereas if you want to sit in a virtual local area and access the Internet from it, then you need to install a different operator –network=bridge:virbr0 what I missed during installation, and then I had to change it manually in the virtual machine settings file /etc/libvirt/qemu/win7.xml.

The machine is controlled in the CLI through virsh (virtual shell) which we access from command line shell:
# virsh --connect qemu:///system
Welcome to virsh, the virtualization interactive terminal.
Type: ‘help’ for help with commands
'quit' to quit
virsh #list –all
ID Name State
—————————————————-
2 win7 running
virsh # shutdown win7
Domain win7 is being shutdown
virsh # start win7
Domain win7 started

If you are reading this article, then most likely you understand perfectly well why you need a web server and I will not dwell on this. But simply describing how CentOS 7 is installed and how to set up the environment seemed uninteresting to me. Therefore, we will take Windows, VirtualBox and set up a web server in a virtual machine, on a virtual network. As a parallel task, in addition to figuring out how to install and configure a web server on Linux, we will create a convenient environment similar to OpenServer or Denwer, but with all the advantages of a full-fledged nix server.

What do we need

Creating a virtual machine container for CentOS in VirtualBox

Launch VirtualBox, go to settings and look at the virtual network configuration:

Ok, network 192.168.56.0/24, DHCP distributes addresses from 101 to 254. Let's remember this information.

Let’s move on to creating a container for CentOS 7. To do this, click on the “Create” button and switch to “Expert Mode”.
OS type – Linux, Version – RedHat (64-bit). We will set the amount of RAM to 512 MB, we will only work in the console, so this will be enough for us with a reserve. We create a new hard drive.


Click the “Create” button and define the configuration hard drive– you can leave everything as default: size 8GB (you can immediately increase it if you realize that you won’t have enough), VDI type, Dynamic. Click the “Create” button again.

The container for the virtual machine has been created. Let's adjust the settings a little:

On the “System” -> “Motherboard” tab, change the boot order:


We put 2 pieces in “Processors” and tick PAE/NX


Go to “Display” and add video memory up to 16 MB. Graphics acceleration is of no use to us, because... We only have a console.


Let's go to the media and specify our image with CentOS 7.




Net. We will use 2 interfaces. The first one is in bridge mode. In the “Name” selector, select the interface through which you connect to your router. This will allow the virtual machine to get an IP from your home network, which is often useful and it will receive the Internet from your router. If this is not the case for you (go online without a router), or you plan that your virtual machine will always need the Internet, use NAT.


For the second interface, select “ Virtual adapter host" to connect to the virtual network. Thanks to this, your web server will be available no matter what network you are working on. If we limited ourselves to only the first adapter, then as soon as you disconnect from your router, you would have to reconfigure network connection under new conditions. And so the web server will always be available to you on the virtual network.


Well, the last step is to disconnect USB. It's unlikely we'll need it.


That's all, let's launch the virtual machine.

Running the CentOS 7 installer

If you did everything correctly, the installer will start and the installation of CentOS 7 will begin (and if it doesn’t start, check again the boot order and that the iso with the CentOS 7 distribution is specified in the media). Select the first item - Install CentOS 7 (note that by default the second item “Test this media..." is selected - if you select it, you can wait until the image checksums are checked, or you can press Esc during the check).

At the first step, we are asked to select the installer language. We leave everything as is and click the Contunue button.


The second step is the main installer menu.


Setting localization and date/time

We will leave the date/time and language settings as they are. We will then configure these points manually - this is useful as practice. If you buy a VDS, for example, in Germany, it is difficult to expect that the language settings will be Russian and the time will be set according to Moscow.

Selecting a security profile

Setting up a security profile – SECURITY. Click Security Policy and select Standard System Security Profile. Click the “Select Profile” button, then “Done”.


Selecting a disk to install and disabling kdump

Let's move on to the SYSTEM group.

Let's disable the mechanism for collecting information about KDUMP kernel failures. Go to KDUMP, uncheck “Enable kdump” and click “Done”.

We will leave the same partitioning for the hard drive unchanged. Click “Installation destination”, select our HDD. Make sure the “Automatically configure partitions” checkbox is checked and click “Done”.


Network configuration

Let's move on to setting up network interfaces. Click NETWORK&HOST NAME and go to the configuration window. First of all, set the hostname for your server - for me it’s web.local, you can repeat after me or write whatever you want.

Now let's look at the list of network interfaces. Our first one is for the Internet; it receives settings from the router via DHCP or via NAT. Let's turn it on by setting the switch to ON. The status should change to connected and the interface should receive an IP address.


Now click the “Configure” button and on the “General” tab check the “Automatically connect to the...” checkbox so that when the operating system boots, the interface is immediately enabled.
Disable IPv6 (of course, if you don’t use it 😉) On the “IPv6 Settings” tab, set “Method” to Ignore. Click “Save”.

Let's move on to the second interface. We turn it on, and we see that we have already received the IP address from the DCHP virtual network. But an address that may change at some point is not suitable for us. Let's set it to static. Click “Configure” and first of all, by analogy with the first interface, set automatic switching on and disable IPv6. Then go to the “IPv4 Settings” tab. “Method” select Manual, in the Addresses list click Add and add an IP address.

Do you remember how we memorized the virtual network settings above? DHCP distributes addresses starting from 56.101, so we need to choose an address less than 101. I chose 192.168.56.80. Set the subnet mask to 24 and click “Save”. Network setup is complete, click “Done”.

Well, the installation of CentOS 7 is almost complete. Click the “Begin Installation” button and the installation process starts.


Root password and user to work with

While the installation is underway, we will set the administrator password.

You can also create account from which we will work. Click “USER CREATION” and set a login, password and check the “Make this user administrator” checkbox to place our user in the wheel group. Please note that if you set a password that the installer considered weak, then you will need to press the “Done” button twice. Of course, such passwords cannot be set on public servers, but for the purposes of our task, there is no need to be too clever with the password.

Now you just have to wait a little while all the packages are installed and click the Reboot button when finished. Congratulations, your CentOS 7 installation is complete.


Running a virtual machine with CentOS 7

Running a virtual machine in VirtualBox is possible in three modes:

1. Normal launch. In this case, the virtual machine will boot in a regular window, which will be present in one way or another on your desktop or minimized on the taskbar. This, of course, is not entirely convenient, especially when the virtual machine intercepts the mouse.
2. Run in the background. In this case, the virtual machine is launched by a background process and after it has loaded, we can safely close the main VirtualBox window. The process will remain and we can, for example, easily connect to the server via ssh.
3. And finally launch in the background with the interface. The virtual machine will boot in the window, but if necessary, we can send it to the background.

Running in the background is, of course, very convenient, but the lack of any indication of the state of the virtual machine or simply the fact of such a launch is very annoying. But the world is not without good people, and here the utility will help us. It launches the selected virtual machine in the background and places an icon in the tray.

By right-clicking on the icon, we will see a menu with which you can manage the running virtual machine. Agree, it’s much more convenient to do it this way.

Connecting via ssh using putty

It is much more convenient to work with the server using an ssh client. For many years now, putty has remained the standard for win systems. I won’t go into detail about all the settings of this client, let’s just connect to our server. Launch putty and enter the IP address of our server 192.168.56.80 into “HostName”. We will connect to it constantly, so let's save this IP in the list. In “Saved Sessions” enter a name and click the “Save” button. To connect, click “Open”.


and we see the invitation line of our server:

After the installation of CentOS 7 is completed, we need to make a lot of settings to customize the server for ourselves. More on this in the next part.

KVM is a virtualization framework for Linux for which a processor with hardware virtualization extension can host guests.

KVM is a convenient solution for testing various operating systems if you are unable to purchase expensive and power-hungry physical devices.

The guide below introduces installation and configuration of KVM (QEMU) along with Linux Bridge configuration on CentOS7/RedHat7 operating system.

1. Check CPU hardware virtualization support

Our processor must support hardware virtualization (VT-x) to become a Hypervisor KVM and host virtual machines (guests). OS):

# lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 4 On-line CPU(s) list: 0-3 Thread(s) per core: 2 Core(s) per socket: 2 Socket(s): 1 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 42 Model name: Intel(R) Core(TM) i5-2520M CPU @ 2.50 GHz Stepping: 7 CPU MHz: 800.000 BogoMIPS: 4988.58 Virtualization: VT-x L1d cache: 32K L1i cache: 32K L2 cache: 256K L3 cache: 3072K NUMA node0 CPU(s): 0-3

2. Disable and stop NetworkManager

NetworkManager is known to cause problems when running Linux Bridge, so it's best for us to disable it:

# systemctl stop NetworkManager # systemctl disable NetworkManager Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service. Removed symlink /etc/systemd/system/dbus-org.freedesktop.NetworkManager.service. Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.

3. Install KVM related packages

# yum install qemu-kvm qemu-img libvirt libvirt-python libvirt-client virt-install virt-viewer virt-manager

4. Start and enable the libvirtd daemon

# systemctl enable libvirtd # systemctl start libvirtd

5. Set system-wide privileges for KVM

We need to add our regular user tuxfixer to the kvm group so that he can run virt-manager

# usermod -a -G kvm tuxfixer

We also need to install polkit (policy kit) rules for KVM.
Edit the file 49-polkit-pkla-compat.rules:

# vim /etc/polkit-1/rules.d/49-polkit-pkla-compat.rules

and add the following:

Polkit.addRule(function(action, subject) ( if (action.id == "org.libvirt.unix.manage" && subject.isInGroup("kvm")) ( return polkit.Result.YES; ) ));

6. Create a KVM Linux Bridge (KVM hypervisor modem network interface to VM network interfaces)

In this tutorial we want to virtual machines got their IP addresses from the same network where the KVM Hypervisor host is connected, so we will connect its main network interface (em1) to the VM network interfaces.

To do this, we need to create a Linux Bridge from the em1 interface on the KVM Hypervisor host.

Current Hypervisor network configuration (immediately after installing KVM):

# ip a 1: lo: mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6::1/128 scope host valid_lft forever preferred_lft forever 2: em1: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether d0:67:e5:33:15:3f brd ff:ff:ff:ff:ff :ff inet 192.168.2.3/24 brd 192.168.2.255 scope global dynamic em1 valid_lft 73193sec preferred_lft 73193sec inet6 fe80::d267:e5ff:fe33:153f/64 scope link valid_lft forever preferred_lft forever 3: wlp3s0: mtu 1500 qdisc noop state DOWN qlen 1000 link/ether 00:24:d7:f4:dc:e8 brd ff:ff:ff:ff:ff:ff 4: virbr0: mtu 1500 qdisc noqueue state DOWN link/ether 52:54:00:b7:22: b3 brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever 5: virbr0-nic: mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 500 link/ether 52 :54:00:b7:22:b3 brd ff:ff:ff:ff:ff:ff

Ifcfg-em1 configuration file (before creating the KVM Linux Bridge):

# cat /etc/sysconfig/network-scripts/ifcfg-em1 DEVICE="em1" TYPE="Ethernet" BOOTPROTO="none" NAME="em1" ONBOOT="yes" HWADDR="D0:67:E5:33: 15:3F" IPADDR=192.168.2.3 PREFIX=24 GATEWAY=192.168.2.1 PEERDNS="no" NM_CONTROLLED="no"

To configure the KVM network we will use the virt-manager application, which is user-friendly interface GUI for the KVM command line interface.

Note. The virbr0 interface was created automatically with the KVM installation and represents virtual network, existing “inside” a KVM environment with NAT (Network Address Translation).

Since we don't need NAT in the KVM environment (we want to hide the Hypervisor interface), we can delete the existing KVM virtual network based on the virbr0 interface.

Run virt-manager as root user:

# virt-manager

... the virt-manager window should appear:

Right click on QEMU/KVM -> Details -> Virtual Networks -> Disable network: “default” -> Delete network: “default” based on virbr0

Now we can connect the Hypervisor KVM interface (em1):

Right click: QEMU/KVM -> Details -> Network Interfaces -> Add Interface:

  • Interface type: Bridge
  • Interface name: br-em1
  • Start mode: on boot
  • Activate now: enabled
  • IP settings: copy configuration from 'em1'
  • Bridge settings: STP on, delay 0.00 sec

...click Finish to override the existing configuration and create the KVM Linux Bridge.

Now we can test the newly created Linux Bridge (br-em1):

Check the current IP configuration (the IP is now assigned to br-em1 and em1 now only acts as an interface):

# ip a 1: lo: mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6::1/128 scope host valid_lft forever preferred_lft forever 2: em1: mtu 1500 qdisc pfifo_fast master br-em1 state UP qlen 1000 link/ether d0:67:e5:33:15:3f brd ff:ff:ff :ff:ff:ff 3: wlp3s0: mtu 1500 qdisc noop state DOWN qlen 1000 link/ether 00:24:d7:f4:dc:e8 brd ff:ff:ff:ff:ff:ff 6: br-em1: mtu 1500 qdisc noqueue state UP link/ether d0:67:e5:33:15:3f brd ff:ff:ff:ff:ff:ff inet 192.168.2.3/24 brd 192.168.2.255 scope global br-em1 valid_lft forever preferred_lft forever inet6 fe80::d267:e5ff:fe33:153f/64 scope link valid_lft forever preferred_lft forever

Check the bridge setup:

# brctl show bridge name bridge id STP enabled interfaces br-em1 8000.d067e533153f yes em1

Now the KVM Linux bridge is configured, and we can continue installing the virtual machine.