1. 安装基础
1
| sudo apt install -y qemu-kvm virt-manager libvirt-clients virt-viewer libvirt-daemon-system bridge-utils virtinst
|
将你的用户添加到libvirt,方便rootless管理
1 2 3
| su -l adduser 你的账户 libvirt
|
2.网络配置
2.1 网卡
检查已有网络
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| ip addr show
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: enp6s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000 link/ether 2a:03:3e:20:0a:00 brd ff:ff:ff:ff:ff:ff inet 192.168.0.99/24 brd 192.168.0.255 scope global dynamic noprefixroute enp6s0 valid_lft 40724sec preferred_lft 40724sec inet6 240e:388:8aff:5500::489/128 scope global dynamic noprefixroute valid_lft 1425sec preferred_lft 1425sec inet6 240e:388:8aff:5500:b65c:688b:f9ec:16b3/64 scope global temporary dynamic valid_lft 1426sec preferred_lft 1426sec inet6 240e:388:8aff:5500:2803:3eff:fe20:aa8/64 scope global dynamic mngtmpaddr noprefixroute valid_lft 1426sec preferred_lft 1426sec inet6 fe80::2803:3eff:fe20:aa8/64 scope link noprefixroute valid_lft forever preferred_lft forever
|
检查虚拟网络并初始化
1 2 3 4 5 6 7 8
| virsh net-list --all virsh net-start default virsh net-autostart default
virsh net-list --all
modprobe vhost_net
|
2.2 增强桥接网卡
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| brctl show
brctl addbr br0
brctl addif br0 enp6s0 brctl show
vim /etc/network/interfaces.d/br0
auto br0 iface br0 inet dhcp bridge_ports enp6s0
systemctl restart networking
|
3. 启动KVM
应用里可以直接启动,virtual machine。