Product SiteDocumentation Site

2.59. net-destroy

Shuts down a virtual network, releasing any resources in use by it.
Usage
net-destroy --network network-identifier
Options
Name Required? Description
--network network-identifier
required
The name or UUID of the network to be shut down.
The word "--network" itself is optional.
Table 2.5. Options

Availability
Available from libvirt 0.2.0 onwards
Platform or Hypervisor specific notes
Linux
If the virtualisation host is running Linux, the name the operating system uses for the network interface can be found using the net-dumpxml virsh command.
Look for the name value of the bridge line. virbr100 in this instance:
virsh # net-dumpxml examplenetwork
<network>
  <name>examplenetwork</name>
  <uuid>b7005dec-be1a-fe9a-338a-0cb1301dfcfd</uuid>
  <forward mode='route'/>
  <bridge name='virbr100' stp='on' delay='0' />
  <ip address='10.10.120.1' netmask='255.255.255.0'>
  </ip>
</network>
Using ifconfig, or a similar tool such as ip, the virbr100 interface will be seen on the host when the virtual network is running:
# ifconfig virbr100
virbr100  Link encap:Ethernet  HWaddr D2:43:D9:47:FA:AA  
inet addr:10.10.120.1  Bcast:10.10.120.255  Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0 
RX bytes:0 (0.0 b)  TX bytes:1553 (1.5 KiB)
After shutting down a virtual network with the net-destroy command, the Linux OS will no longer show this interface:
# ifconfig virbr100
virbr100: error fetching interface information: Device not found
Examples
virsh # net-destroy mynetwork
Shuts down the virtual network named "mynetwork".
virsh # net-destroy --network mynetwork
Same as the above example.
virsh # net-destroy bfbc4c69-7d6a-cc9a-904c-09910ce179c0
Shuts down the virtual network that has a UUID of "bfbc4c69-7d6a-cc9a-904c-09910ce179c0".
virsh # net-destroy --network bfbc4c69-7d6a-cc9a-904c-09910ce179c0
Same as the above example.
Example in context
Starting with a virtual network named examplenetwork, already running on a virtualisation host server:
virsh # net-list
Name                 State      Autostart
-----------------------------------------
default              active     yes
examplenetwork       active     yes
The network is shut down by simply using the net-destroy command on it:
# net-destroy examplenetwork
Network examplenetwork destroyed
The command now shows it as inactive:
virsh # net-list --all
Name                 State      Autostart
-----------------------------------------
default              active     yes
examplenetwork       inactive   yes
See also
  • net-create - Creates a running, transient virtual network, using settings from an XML file.
  • net-list - Displays a list of the virtual networks libvirt is aware of.
  • net-start - Manually starts a virtual network that isn't running.