Setting up networking for KVM/Libvirt

tested on mint21.1/ubuntu22.04

ubuntu

this gets enabled by default

virsh net-list --all

debian

you need to proceed manually

virsh net-start default
virsh net-autostart default

shared

that should be enabled already

sysctl net.ipv4.ip_forward

and check

assuming table filter chain forward NAT –> accept

brctl show virbr0
ifconfig virbr0
iptables -t nat -nvL
netstat -lntup | grep 192.168.122.1:53

diy nat & bridge

the other way around is to NAT with NETFILTER

virsh net-autostart default --disable
virsh net-destroy default

setup a bridge

# brctl addbr dummybr0
# ifconfig dummybr0 192.168.122.1/24 up

vi /etc/network/interfaces

    auto dummybr0
    iface dummybr0 inet static
            address 192.168.122.1/24
            bridge_ports none

then point the guests against it

# --network bridge=xenbr0,model=virtio \

vi /data/guests/$guest/$guest.xml

    <interface type='bridge'>
      <source bridge='dummybr0'/>
      <model type='virtio'/>
    </interface>

diy stub dns

cp -pi /etc/systemd/resolved.conf /etc/systemd/resolved.conf.dist
vi /etc/systemd/resolved.conf

DNSStubListenerExtra=192.168.122.1

systemctl restart systemd-resolved.service
netstat -lntup | grep -E ':53[[:space:]]'

resources

stub dns

https://unix.stackexchange.com/questions/445782/how-to-allow-systemd-resolved-to-listen-to-an-interface-other-than-loopback

https://www.freedesktop.org/software/systemd/man/resolved.conf.html#DNSStubListenerExtra=


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Copyright © 2024 Pierre-Philipp Braun