ubuntu add default network(nat) to libvirt

Every standard libvirt installation provides NAT based connectivity to virtual machines out of the box. This is the so called 'default virtual network'. You can verify that it is available with:
# virsh net-list --all
Name                 State      Autostart 
-----------------------------------------
default              active     yes
If it is missing, then the example XML config can be reloaded & activated:
If there is not networks folder in the path /usr/share/libvirt create it:
sudo mkdir /usr/share/libvirt/networks
then create a file which name is defalt.xml and change its mod:
cd /usr/share/libvirt/networks
sudo touch default.xml
sudo chmod 777 default.xml
edit the default.xml,add default network:
<network>
   <name>default</name>
   <bridge name="virbr0" />
   <forward/>
<ip address="192.168.122.1" netmask="255.255.255.0">
     <dhcp>
       <range start="192.168.122.2" end="192.168.122.254" />
     </dhcp>
   </ip>
</network>
Now that the xml file has been created, we can use virsh net-define to define it.
# virsh net-define /usr/share/libvirt/networks/default.xml
Network default defined from /usr/share/libvirt/networks/default.xml
And we can see the network show up in virsh net-list:
# virsh net-list --all
Name                 State      Autostart
-----------------------------------------
default              inactive     no             
But as can be seen above, the network is not active, nor set to autostart. So let’s do that:
# virsh net-autostart default
Network default marked as autostarted
# virsh net-start default
Network default started
see it:
# virsh net-list
Name                 State      Autostart
-----------------------------------------
default              active     yes       



references:
Adding networks to libvirt: http://serverascode.com/2014/04/26/adding-networks-libvirt.html
wiki libvirt using QEMU/KVM with libvirt on Ubuntu: http://wiki.libvirt.org/page/UbuntuKVMWalkthrough
wiki libvirt Networking: http://wiki.libvirt.org/page/Networking

你可能感兴趣的:(ubuntu,NetWork,default,libvirt)