Installation of KVM( Kernel-based Virtual Machine) Virtualization and Eve-NG in CentOS

Installation of KVM and Eve-NG

 Kernel-based Virtual Machine or KVM is an open source virtualization solution that can make your Linux Server as hypervisor. I will demonstrate also how to install Virtual Machine (VM), for this example I will install Eve-NG (Emulated Virtual Environment) which is used by Network Engineers or Security and DevOps professionals to emulate different network devices/platforms such as Cisco,Juniper, Arista, Linux and so much more, mainly for POC, testing and learning.

Tested in CentOS 7
See first if your server supports Virtualization

# lscpu | grep Virt
Virtualization: VT-x

  1. Install KVM
    yum install qemu-kvm virt-install libvirt libvirt-python libguestfs-tools

Start the libvirtd service
systemctl enable libvirtd
systemctl start libvirtd

Check if it is running:

# systemctl status libvirtd

● libvirtd.service – Virtualization daemon
Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2019-08-02 22:05:35 +08; 23h ago
Docs: man:libvirtd(8)
https://libvirt.org
Main PID: 14880 (libvirtd)
Tasks: 20 (limit: 32768)
CGroup: /system.slice/libvirtd.service
├─14880 /usr/sbin/libvirtd
├─14979 /usr/sbin/dnsmasq –conf-file=/var/lib/libvirt/dnsmasq/default.conf –leasefile-ro –dhcp-script=/usr/libexec/libvirt_leaseshelper
└─14980 /usr/sbin/dnsmasq –conf-file=/var/lib/libvirt/dnsmasq/default.conf –leasefile-ro –dhcp-script=/usr/libexec/libvirt_leaseshelper

Verify if kvm is installed

# lsmod | grep -i kvm

kvm_intel 183737 10
kvm 615914 1 kvm_intel
irqbypass 13503 4 kvm

 

2.Configure bridge network
e.g. primary interface = enp3s0f0
a. add line BRIDGE=br0 under /etc/sysconfig/network-scripts/enp3s0f0 , save and exit
b. configure bridge interface,e.g. br0
if dhcp:
Add the following in /etc/sysconfig/network-scripts/ifcfg-br0

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

DEVICE=”br0″
BOOTPROTO=”dhcp”
IPV6INIT=”yes”
IPV6_AUTOCONF=”yes”
ONBOOT=”yes”
TYPE=”Bridge”

if static:(IP: 192.168.0.200/24, GW: 192.168.0.1, DNS:192.168.0.10
TYPE=Bridge
BOOTPROTO=none
DEFROUTE=yes
NAME=br0
DEVICE=br0
ONBOOT=yes
IPADDR=192.168.0.200
PREFIX=24
GATEWAY=192.168.0.1
DNS1=192.168.0.10

Restart network service

#service network restart

Verify:

#brctl show

For OpenVswitch:
sample contents of /etc/sysconfig/network-scripts/enp3s0f0

vi /etc/sysconfig/network-scripts/enp3s0f0

TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=no
IPV6_DEFROUTE=no
IPV6_FAILURE_FATAL=no
NAME=enp3s0f0
DEVICE=enp3s0f0
ONBOOT=yes
TYPE=”OVSPort”
DEVICETYPE=”ovs”
OVS_BRIDGE=”br0

sample contents of /etc/sysconfig/network-scripts/ifcfg-br0

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

TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
NAME=br0
UUID=1e9b47ec-a06e-4e9e-a78d-ffae0571bed7
DEVICE=br0
ONBOOT=yes
IPADDR=192.168.0.200
PREFIX=24
GATEWAY=192.168.0.1
DNS1=192.168.0.10

3. Install Eve-NG as Virtual Machine
Specifications:
OS:Ubuntu/EVE-NG
RAM: 4GB
VCPU: 4
Image Loc: /home/images
Disk Size: 40GB

Download the ISO of EVE-NG Community version at https://www.eve-ng.net/downloads/eve-ng   and upload it on your server.

cd /var/lib/libvirt/boot/

#virt-install –virt-type=kvm –name eve-ng –ram 8192 –vcpus=8 –os-variant=ubuntu16.04 –cdrom=/var/lib/libvirt/boot/EVE-20171007.iso –network=bridge=br0,model=virtio –graphics vnc –disk path=/home/images/eve-ng.qcow2,size=40,bus=virtio,format=qcow2

WARNING Graphics requested but DISPLAY is not set. Not running virt-viewer.
WARNING No console to launch for the guest, defaulting to –wait -1

Starting install…
Allocating ‘eve-ng.qcow2’ | 40 GB 00:00:04

For OVS, need to add the option (virtualport_type=openvswitch) else you will get this error message (“ERROR Unable to add bridge brX port vnet0: Operation not supported)

#virt-install –virt-type=kvm –name eve-ng –ram 8192 –vcpus=8 –os-variant=ubuntu16.04 –cdrom=/var/lib/libvirt/boot/EVE-20171007.iso –network=bridge:br-ex,model=virtio,virtualport_type=openvswitch –graphics vnc –disk path=/home/images/eve-ng.qcow2,size=40,bus=virtio,format=qcow2

WARNING Graphics requested but DISPLAY is not set. Not running virt-viewer.
WARNING No console to launch for the guest, defaulting to –wait -1

Starting install…
Allocating ‘eve-ng.qcow2’ | 40 GB 00:00:04
Domain installation still in progress. Waiting for installation to complete.

Open a new session and check the vnc port settings

# virsh dumpxml eve-ng | grep vnc

Setup SSH tunnel to access the remove VNC server
ssh tux@192.168.0.200 -L 5900:127.0.0.1:5900

4. Connect to VM
Open VNC client and input settings as below. Start the Eve-NG installation(Install EVE as Bare).
Host: localhost or 127.0.0.1
Port: 5900

During installation, you will be prompted to configure the network settings

Test Eve-NG by accessing through the browser or SSH it

Web:http://192.168.0.200
SSH: ssh root@192.168.0.200
root@eve-ng:~# cat /etc/network/interfaces

iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.0.200
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 192.168.0.10

Share

About the author

Free Linux

View all posts

Leave a Reply