1. 虚拟机创建固定ip

1. 查看虚拟机mac地址和使用的虚拟网卡

$ virsh dumpxml k8s-work1 | grep -E 'source network|mac address'
      <mac address='52:54:00:25:ab:8f'/>
      <source network='default' portid='ce03f8f3-f892-46d5-8448-8bc03844bd03' bridge='virbr0'/>

2. 修改libvirt网络配置

ip address中配置静态IP

$ virsh net-edit default 
 <ip address='192.168.122.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.122.2' end='192.168.122.254'/>
      <host mac='52:54:00:25:ab:8f' name='k8s-work1' ip='192.168.122.123'/></span>
    </dhcp>
  </ip>

3. 保存退出,重启网络

virsh net-destroy default
virsh net-start default