[Linux] ubuntu 20.04 install kvm with bridge network
Install
KVM
Before Install Check
kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used
Install KVM Package
apt install qemu-kvm libvirt-daemon-system \
libvirt-clients virtinst bridge-utils -y
Check And Start libvirt
systemctl status libvirtd
systemctl start libvirtd
Change Host Network Setting
Old Conf
network:
ethernets:
enp2s0:
addresses:
- 172.19.0.7/24
gateway4: 172.19.0.254
nameservers:
addresses:
- 172.19.0.1
search:
- ngu.tw
version: 2
New conf
network:
ethernets:
enp2s0:
dhcp4: false
dhcp6: false
bridges:
br0:
interfaces: [ enp2s0 ]
addresses: [172.19.0.7/24]
gateway4: 172.19.0.254
mtu: 1500
nameservers:
addresses: [172.19.0.2,172.19.0.1]
parameters:
stp: true
forward-delay: 4
dhcp4: no
dhcp6: no
version: 2
Apply Network Setting
netplan apply
Change KVM Network
destroy default network
virsh net-destroy default
virsh net-undefine default
add new network, create file call bridge-host.xml
<network>
<name>bridge-host</name>
<forward mode="bridge"/>
<bridge name="br0"/>
</network>
setting KVM
network and check it
virsh net-define bridge-host.xml
virsh net-start bridge-host
virsh net-autostart bridge-host
virsh net-list --all
Used
Create VM
Add HDD
qemu-img create -f qcow2 \
/your/images/path/ubuntu20.04.qcow2 25G
Create VM
virt-install --virt-type kvm --name temp20.04 \
--ram 2048 --disk /your/images/path/ubuntu20.04.qcow2\
,format=qcow2 --network network=bridge-host \
--graphics vnc,listen=0.0.0.0,\
password=YOUR_PASSWORD \
--cdrom=/data/kvm/iso/ubuntu-20.04.1-live-server-amd64.iso