KVM virsh net-create (create network) example

net-create file

Create a transient (temporary) virtual network from an XML file and instantiate (net-start) the network. See the documentation at http://libvirt.org/formatnetwork.html to get a description of the XML network format used by libvirt.

This is similar to net-define, but doesn't make the network persistent.


# cat ./new-net 
<network>
  <name>new-net</name>
  <uuid>6f326541-795e-468a-be13-54369b916aeb</uuid>
  <forward mode='nat'>
    <nat>
      <port start='1024' end='65535'/>
    </nat>
  </forward>
  <bridge name='virbr1' stp='on' delay='0'/>
  <mac address='52:54:00:cd:bc:89'/>
  <ip address='192.168.122.3' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.122.4' end='192.168.122.254'/>
    </dhcp>
  </ip>
</network>


# virsh net-create ./new-net
Network new-net created from ./new-net

# virsh net-list  --all    
 Name                 State      Autostart     Persistent
----------------------------------------------------------
 default              inactive   yes           yes
 new-net              active     no            no

To make this network persistent use net-define.

# sudo virsh net-define new-net  
Network new-net defined from new-net
Edit Report
Pub: 22 Jan 2018 13:09 UTC
Edit: 22 Jan 2018 13:13 UTC
Views: 1678