1、桥接网络-bridge
2、NAT网络
2.1、kvm 默认的网络模式
配置文件:/etc/libvirt/qemu/networks/default.xml
<network>
<name>default</name>
<uuid>0d5ad6d1-0150-4bef-bd82-9589d62e841f</uuid>
<forward mode='nat'/>
<bridge name='virbr0' stp='on' delay='0'/>
<mac address='52:54:00:83:fe:35'/>
<ip address='192.168.124.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.124.2' end='192.168.124.254'/>
</dhcp>
</ip>
</network>
#virsh
virsh # net-dumpxml default
也可以查看网络的配置信息
2.2、创建nat网络
cp /etc/libvirt/qemu/networks/default.xml /etc/libvirt/qemu/networks/nat1.xml
<network>
<name>nat1</name> #名字修改
<uuid>0d5ad6d1-0150-4bef-bd83-9589d62e841f</uuid> #id需唯一
<forward mode='nat'/>
<bridge name='virbr1' stp='on' delay='0'/> #名字修改
<mac address='52:54:00:86:fe:35'/> #只能修改后三位,保证唯一
<ip address='192.168.120.1' netmask='255.255.255.0'> #修改
<dhcp>
<range start='192.168.120.2' end='192.168.120.254'/> #修改
</dhcp>
</ip>
</network>
systemctl restart libvirtd
2.3、激活
virsh # net-list #查看网络接口列表
3、隔离网络-isolated
3.1、创建隔离网络
cp /etc/libvirt/qemu/networks/default.xml /etc/libvirt/qemu/networks/isolated200.xml
<network>
<name>isolated200</name>
<uuid>0d5ad6d1-0130-4bef-bd82-9589d62e841f</uuid>
<bridge name='virbr2' stp='on' delay='0'/>
<mac address='52:54:00:82:fe:35'/>
<ip address='192.168.200.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.200.2' end='192.168.200.254'/>
</dhcp>
</ip>
</network>
systemctl restart libvirtd
3.2、激活网卡
#激活网卡
virsh net-start isolated200
#自动启动
virsh net-autostart isolated200
#查看虚拟的网卡
virsh domiflist centos7.0