<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Libvirt on nagg.eu</title><link>https://nagg.eu/tags/libvirt/</link><description>Recent content in Libvirt on nagg.eu</description><generator>Hugo</generator><language>en</language><lastBuildDate>Sun, 25 Jul 2021 00:00:00 +0000</lastBuildDate><atom:link href="https://nagg.eu/tags/libvirt/index.xml" rel="self" type="application/rss+xml"/><item><title>Debian QEMU/KVM bridged networking and VLAN</title><link>https://nagg.eu/debian-qemu-kvm-bridged-networking-and-vlan/</link><pubDate>Sun, 25 Jul 2021 00:00:00 +0000</pubDate><guid>https://nagg.eu/debian-qemu-kvm-bridged-networking-and-vlan/</guid><description>&lt;p&gt;By default on every Linux distro after installing &lt;code&gt;QEMU&lt;/code&gt; and &lt;code&gt;libvirt&lt;/code&gt; two
kinds of networking are available:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;NAT: VM sits behind a NAT.&lt;/li&gt;
&lt;li&gt;MACVTAP: without going into much details it acts more or less like a
bridged network, except not really. One of the most annoying limitations is
that host to guest communication and vice versa are not really working well.
Other important things might be broken as well, like for example VRRP.
This mode is good for quick and dirty testing but not really for a stable
environment.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;BRIDGED networking is also supported by &lt;code&gt;libvirt&lt;/code&gt; but requires some manual
work.&lt;br&gt;
A possible networking schema could be the following:&lt;/p&gt;</description></item><item><title>Keepalived and libvirt MACVTAP network interfaces</title><link>https://nagg.eu/keepalived-and-libvirt-macvtap-network-interfaces/</link><pubDate>Wed, 13 Jan 2021 00:00:00 +0000</pubDate><guid>https://nagg.eu/keepalived-and-libvirt-macvtap-network-interfaces/</guid><description>&lt;p&gt;Keepalived is a routing software written in C that can be used to setup load
balancing and high availiability for Linux machines.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;NOTE: hypervisor is Debian 10 (Buster) with &lt;code&gt;libvirt&lt;/code&gt; and &lt;code&gt;qemu/kvm&lt;/code&gt;, virtual
machines also are Debian 10 (Buster).&lt;/em&gt;&lt;/p&gt;
&lt;h2 id="keepalived-configuration"&gt;Keepalived configuration&lt;/h2&gt;
&lt;p&gt;Install &lt;code&gt;keepalived&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;$ apt install keepalived
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Install &lt;code&gt;nginx&lt;/code&gt;, it will be use to check that keepalived is actually working:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;$ apt install nginx
$ systemctl enable --now nginx
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Configure &lt;code&gt;keepalived&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;$ vi /etc/keepalived/keepalived.conf
---
global_defs {
 enable_script_security # prevents tampering with the check script
 script_user root # defines which user runs the check script
}

vrrp_script chk_nginx {
 script &amp;#34;/opt/scripts/nginx-check.sh&amp;#34;
 interval 2 # run script every 2 seconds
 weight 2 # add 2 points if OK
}

vrrp_instance VI_1 {
 interface enp2s0 # interface to monitor
 virtual_router_id 51
 priority 101 # MASTER 101, BACKUP 100
 advert_int 1
 nopreempt # comment to not have the VIP go back to MASTER 
 # -&amp;gt; when it comes back online
 authentication {
 auth_type PASS
 auth_pass myPass # maximum 8 chars
 }
 virtual_ipaddress {
 10.10.0.12/24 # VIP (Virtual IP Address)
 }
 track_script {
 chk_nginx
 }
}
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Also add a script to check if &lt;code&gt;nginx&lt;/code&gt; is alive and well:&lt;/p&gt;</description></item></channel></rss>