美文网首页
ubuntu 20.04 安装KVM

ubuntu 20.04 安装KVM

作者: helphi | 来源:发表于2020-09-08 14:43 被阅读0次

on Ubuntu 20.04 Server

cp /usr/share/zoneinfo/Asia/Shanghai  /etc/localtime

# 安装kvm相关命令
apt install virtinst libvirt-daemon-system bridge-utils cloud-utils libguestfs-tools virt-top

# nmcli 指令创建系统桥接网卡(这种方式适合使用NetworkManager托管网络的系统)
nmcli con add type bridge con-name br0 ifname br0 autoconnect yes
nmcli con add type bridge-slave ifname eno1 master br0
nmcli con modify br0 bridge.stp no
nmcli con modify br0 ipv4.method manual ipv4.addresses "192.168.999.999/24" ipv4.gateway "192.168.999.254" ipv4.dns "192.168.999.250"
nmcli con show
nmcli con up br0
nmcli connection down "Wired connection 1"
nmcli con down br0
nmcli con delete br0

# 通过 netplan 配置文件创建系统桥接网卡
cat >br0.xml <<EOF
network:
  version: 2
  ethernets:
    enp1s0:
      dhcp4: false
  bridges:
    br0:
      dhcp4: false
      interfaces: [enp1s0]
      addresses: [192.168.999.999/24]
      gateway4: 192.168.999.254
      nameservers:
        addresses: [192.168.999.250]
      parameters:
        stp: false
EOF
netplan apply

# 在系统桥接网卡上创建虚拟机桥接网卡
cat >br0.xml <<EOF
<network>
<name>br0</name>
<forward mode="bridge"/>
<bridge name="br0"/>
</network>
EOF
virsh net-define br0.xml 
virsh net-autostart br0
virsh net-start br0

相关文章

网友评论

      本文标题:ubuntu 20.04 安装KVM

      本文链接:https://www.haomeiwen.com/subject/lfhpmhtx.html