---
# System prepended metadata

title: IaaS-infra setup.md

---

# setup IaaS-infra

## check VT-x , VT-d is enabled 
`egrep -c '(vmx|svm)' /proc/cpuinfo`

## install KVM 
```
sudo apt install virt-manager qemu-system libvirt-daemon-system qemu-utils libvirt-bin virtinst -y
```

## install libvirt 
```
sudo apt install qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virtinst libvirt-daemon virt-manager -y
sudo systemctl status libvirtd.service
sudo systemctl start libvirtd
sudo systemctl enable libvirtd
```

## setup libvirt default pool 
```
sudo virsh pool-define-as --name default --type dir --target /var/lib/libvirt/images
sudo virsh pool-autostart default
sudo virsh pool-start default
```

## add user to group 
```
sudo usermod -aG libvirt,kvm root
sudo usermod -aG libvirt,kvm <username>
```
## start virsh net-start 
```
sudo virsh net-start default
sudo virsh net-autostart default
```

## install autofs (for CDROM)
```
sudo apt-get install autofs
```

## install python3 package
```
sudo apt-get install python3-libvirt python3-xmltodict
```

## install openvswitch-switch 
```
sudo apt-get install openvswitch-switch
systemctl list-units | grep openvswitch
sudo systemctl enable openvswitch-switch
sudo systemctl start openvswitch-switch
```

## adding bridge
```
sudo ovs-vsctl add-br ovsbr0
sudo ovs-vsctl add-port ovsbr0 ens18
sudo ip link set ovsbr0 up
```

## check ovs-vsctl table
`sudo ovs-vsctl show`

## 監聽vlan 內封包
`sudo tcpdump -i ovsbr0 -n -e -vv vlan 1`
