1、桥接网络-bridge

语雀内容

2、NAT网络

2.1、kvm 默认的网络模式

配置文件:/etc/libvirt/qemu/networks/default.xml

  1. <network>
  2. <name>default</name>
  3. <uuid>0d5ad6d1-0150-4bef-bd82-9589d62e841f</uuid>
  4. <forward mode='nat'/>
  5. <bridge name='virbr0' stp='on' delay='0'/>
  6. <mac address='52:54:00:83:fe:35'/>
  7. <ip address='192.168.124.1' netmask='255.255.255.0'>
  8. <dhcp>
  9. <range start='192.168.124.2' end='192.168.124.254'/>
  10. </dhcp>
  11. </ip>
  12. </network>
  1. #virsh
  2. virsh # net-dumpxml default
  3. 也可以查看网络的配置信息

2.2、创建nat网络

cp /etc/libvirt/qemu/networks/default.xml /etc/libvirt/qemu/networks/nat1.xml

  1. <network>
  2. <name>nat1</name> #名字修改
  3. <uuid>0d5ad6d1-0150-4bef-bd83-9589d62e841f</uuid> #id需唯一
  4. <forward mode='nat'/>
  5. <bridge name='virbr1' stp='on' delay='0'/> #名字修改
  6. <mac address='52:54:00:86:fe:35'/> #只能修改后三位,保证唯一
  7. <ip address='192.168.120.1' netmask='255.255.255.0'> #修改
  8. <dhcp>
  9. <range start='192.168.120.2' end='192.168.120.254'/> #修改
  10. </dhcp>
  11. </ip>
  12. </network>
  1. systemctl restart libvirtd

2.3、激活

  1. virsh # net-list #查看网络接口列表

image.png

3、隔离网络-isolated

3.1、创建隔离网络

cp /etc/libvirt/qemu/networks/default.xml /etc/libvirt/qemu/networks/isolated200.xml

  1. <network>
  2. <name>isolated200</name>
  3. <uuid>0d5ad6d1-0130-4bef-bd82-9589d62e841f</uuid>
  4. <bridge name='virbr2' stp='on' delay='0'/>
  5. <mac address='52:54:00:82:fe:35'/>
  6. <ip address='192.168.200.1' netmask='255.255.255.0'>
  7. <dhcp>
  8. <range start='192.168.200.2' end='192.168.200.254'/>
  9. </dhcp>
  10. </ip>
  11. </network>
  1. systemctl restart libvirtd

3.2、激活网卡

  1. #激活网卡
  2. virsh net-start isolated200
  3. #自动启动
  4. virsh net-autostart isolated200
  5. #查看虚拟的网卡
  6. virsh domiflist centos7.0

image.png