想在创建虚拟机的时候指定ip调研

想调研一下libvit xml能否提供类似的配置选项:

 xml应该写成这个样子,预先要在宿主机上面创建br0,配置要分配指定ip

Using an existing host bridge

Since 0.9.4 This shows how to use a pre-existing host bridge "br0". The guests will effectively be directly connected to the physical network (i.e. their IP addresses will all be on the subnet of the physical network, and there will be no restrictions on inbound or outbound connections).

      <network>
        <name>host-bridge</name>
        <forward mode="bridge"/>
        <bridge name="br0"/>
      </network>
 

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.254
bridge_ports eth0

这种配置需要进入客户机OS然后指定ip之后才能使用桥接进入局域网

怎么把新创建的虚拟机加入到网桥中去? 在kvm的启动命令中,vlan=0,1是核心吗?在libvirt中怎么使用?不需要编辑/etc/networking/interface吧?在xml中指定就可以了吧?如果不行 用libvirtAPI 进行调用设置吗? 应该是可以的

 
原文地址:https://www.cnblogs.com/zhangzhang/p/2352386.html