如下命令可以修改默认网段
sudo virsh net-edit --network default
- <network>
- <name>default</name>
- <uuid>45ed012c-3933-4f3e-9575-b37bffa21b83</uuid>
- <forward mode='nat'/>
- <bridge name='virbr0' stp='on' delay='0'/>
- <mac address='52:54:00:03:a7:5b'/>
- <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>
Enable forwarding
echo "net.ipv4.ip_forward=1" | sudo tee /etc/sysctl.conf
- [root@netdev vm]# virsh list --all
- Id Name State
- ------------------------
- 1 ubuntu running
virsh [start/shutdown/destroy] vm
virsh [suspend|resume] vm
virsh autostart vm
查看信息
- [root@netdev vm]# virsh dominfo ubuntu
- Id: 1
- Name: ubuntu
- UUID: dd1e0fee-0f38-4a9a-a515-256bb6a10d16
- OS Type: hvm
- State: running
- CPU(s): 4
- CPU time: 539.3s
- Max memory: 8388608 KiB
- Used memory: 8388608 KiB
- Persistent: yes
- Autostart: disable
- Managed save: no
- Security model: selinux
- Security DOI: 0
- Security label: system_u:system_r:svirt_t:s0:c887,c939 (enforcing)
-
- [root@netdev vm]# virt-clone -o ubuntu -n vm001 -f /home/vm/vm001.qcow2
- Allocating 'vm001.qcow2' | 100 GB 00:00:08
-
- Clone 'vm001' created successfully.
克隆完成后, 需要uuidgen
- [root@netdev vm]# uuidgen
- 10c35319-bd71-4447-aa1a-88207ec42fbf
- [root@netdev vm]# vim /etc/libvirt/qemu/vm001.xml
virsh undefine vm
删除虚机并删除存储
- virsh undefine vm --storage /home/vm/vm.qcow2
- virsh undefine vm