install_kvm.sh 961 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. # Install KVM
  3. apt-get install --no-install-recommends \
  4. qemu-system libvirt-clients libvirt-daemon-system ovmf
  5. # Remove virbr0 NAT interface created during the kvm installation
  6. virsh net-destroy default
  7. virsh net-undefine default
  8. # Create network from exisiting host bridge
  9. cat >/tmp/host-bridge.xml <<EOL
  10. <network>
  11. <name>host-bridge</name>
  12. <forward mode="bridge"/>
  13. <bridge name="br0"/>
  14. </network>
  15. EOL
  16. virsh net-define host-bridge.xml
  17. virsh net-autostart host-bridge
  18. virsh net-start host-bridge
  19. rm /tmp/host-bridge.xml
  20. # Create isolated network (without DHCP)
  21. cat >/tmp/isolated-bridge.xml <<EOL
  22. <network>
  23. <name>isolated-bridge</name>
  24. <forward mode="bridge"/>
  25. <bridge name="br1"/>
  26. </network>
  27. EOL
  28. virsh net-define isolated-bridge.xml
  29. virsh net-autostart isolated-bridge
  30. virsh net-start isolated-bridge
  31. rm /tmp/isolated-bridge.xml
  32. # List networks
  33. virsh net-list