Установка гипервизора KVM на CentOS 7
Отредактирована 27.10.2023
$ lscpu | grep Virtualization
Virtualization: VT-x
Технология Intel® Virtualization для направленного ввода/вывода (VT-x) позволяет одной аппаратной платформе функционировать в качестве нескольких «виртуальных» платформ. Технология улучшает возможности управления, снижая время простоев и поддерживая продуктивность работы за счет выделения отдельных разделов для вычислительных операций.
$ su -
# yum install qemu-kvm libvirt libvirt-python libguestfs-tools virt-install
# systemctl enable libvirtd
# systemctl start libvirtd
# lsmod | grep -i kvm
# yum install bridge-utils
# ip address
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
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: enp1s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master br0 state UP group default qlen 1000
link/ether 00:30:48:df:ba:bc brd ff:ff:ff:ff:ff:ff
inet 192.168.56.4/24 brd 192.168.56.255 scope global noprefixroute enp1s0f0
valid_lft forever preferred_lft forever
inet6 fe80::ad75:6f6d:2a39:1255/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: enp1s0f1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether 00:30:48:df:ba:bd brd ff:ff:ff:ff:ff:ff
4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:0c:84:09 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: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:0c:84:09 brd ff:ff:ff:ff:ff:ff
- enp1s0f0 — физический сетевой интерфейс с настроенным IP-адресом 192.168.56.4/24 , через который идет подключение сервера к локальной сети (из него мы будем делать мост);
- 00:30:48:df:ba:bc — mac-адрес реального ethernet адаптера;
- virbr0 — виртуальный сетевой адаптер.
# cd /etc/sysconfig/network-scripts/
# nano ifcfg-enp1s0f0
TYPE=Ethernet
BOOTPROTO=none
DEVICE=enp1s0f0
ONBOOT=yes
BRIDGE=br0
# nano ifcfg-br0
DEVICE=br0
TYPE=Bridge
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.56.4
PREFIX=24
GATEWAY=192.168.56.1
DNS1=77.88.8.8
DNS2=77.88.8.88
DNS3=77.88.8.7
# systemctl restart network
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
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: enp1s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master br0 state UP group default qlen 1000
link/ether 00:30:48:df:ba:bc brd ff:ff:ff:ff:ff:ff
3: enp1s0f1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether 00:30:48:df:ba:bd brd ff:ff:ff:ff:ff:ff
4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:0c:84:09 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: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:0c:84:09 brd ff:ff:ff:ff:ff:ff
7: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:30:48:df:ba:bc brd ff:ff:ff:ff:ff:ff
inet 192.168.56.4/24 brd 192.168.56.255 scope global noprefixroute br0
valid_lft forever preferred_lft forever
inet6 fe80::230:48ff:fedf:babc/64 scope link
valid_lft forever preferred_lft forever
# nano /etc/sysctl.d/99-sysctl.conf
net.ipv4.ip_forward=1
# sysctl -p /etc/sysctl.d/99-sysctl.conf
# systemctl restart libvirtd