deb http://deb.debian.org/debian/ bullseye main contrib non-freedeb-src http://deb.debian.org/debian/ bullseye main contrib non-freedeb http://security.debian.org/debian-security bullseye-security main contrib non-freedeb-src http://security.debian.org/debian-security bullseye-security main contrib non-freedeb http://deb.debian.org/debian/ bullseye-updates main contrib non-freedeb-src http://deb.debian.org/debian/ bullseye-updates main contrib non-free
apt updateapt install firmware-realtek
apt install -y tmux htop libvirt-daemon-system qemu-kvm libvirt-clients bridge-utils libguestfs-tools genisoimage virtinst libosinfo-bin
apt install sudo
# This file describes the network interfaces available on your system# and how to activate them. For more information, see interfaces(5).source /etc/network/interfaces.d/*# The loopback network interfaceauto loiface lo inet loopback# The primary network interface#allow-hotplug enx000ec6b47101#auto enx000ec6b47101 #iface enx000ec6b47101 inet dhcpauto enp2s0iface enp2s0 inet manualauto br_laniface br_lan inet static bridge_ports enp2s0# bridge_waitport 0 # no delay before a port becomes available# bridge_fd 0 # no forwarding delay# bridge_maxwait 0 address 192.168.10.1 netmask 255.255.255.0 gateway 192.168.10.2 dns-nameservers 192.168.10.2auto enp1s0iface enp1s0 inet manualauto br_waniface br_wan inet manual bridge_ports enp1s0auto enp3s0iface enp3s0 inet manualauto br_dmz1iface br_dmz1 inet manual bridge_ports enp3s0auto enp4s0iface enp4s0 inet manualauto br_dmz2iface br_dmz2 inet manual bridge_ports enp4s0
sudo apt install net-tools
bzip2 -d OPNsense-22.7-OpenSSL-nano-amd64.img.bz2
qemu-img convert -f raw -O qcow2 OPNsense-22.7-OpenSSL-nano-amd64.img opnsense.qcow2
qemu-img resize opnsense.qcow2 +25G
mv opnsense.qcow2 /var/lib/libvirt/images/
<domain type='kvm'> <name>opnsense</name> <memory unit='MiB'>6144</memory> <currentMemory unit='MiB'>6144</currentMemory> <vcpu>4</vcpu> <os> <type arch='x86_64'>hvm</type> <boot dev='hd'/> </os> <features><acpi/><apic/><pae/></features> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <emulator>/usr/bin/qemu-system-x86_64</emulator> <controller type='pci' index='0' model='pci-root'/> <disk type='file' device='disk'> <driver name='qemu' type='qcow2' cache='none'/> <source file='/var/lib/libvirt/images/opnsense201.qcow2'/> <target dev='vda' bus='virtio'/> </disk> <interface type='bridge'> <source bridge='br_wan'/> <model type='virtio'/> <target dev='vnet0'/> <alias name='net0'/> </interface> <interface type='bridge'> <source bridge='br_lan'/> <model type='virtio'/> <target dev='vnet1'/> <alias name='net1'/> </interface> <interface type='bridge'> <source bridge='br_dmz1'/> <model type='virtio'/> <target dev='vnet2'/> <alias name='net2'/> </interface> <interface type='bridge'> <source bridge='br_dmz2'/> <model type='virtio'/> <target dev='vnet3'/> <alias name='net3'/> </interface> <serial type='pty'><target port='0'/></serial> <console type='pty'><target port='0'/></console> <memballoon model='none'></memballoon> </devices></domain>
virsh define opnsense-kvm-config.xml
Start the vm and connect to the vm’s console[code] virsh start opnsense virsh console opnsense
WAN - vtnet0 LAN - vtnet1DMZ1 - vtnet2DMZ2 - vtnet3
virsh autostart opnsense
systemctl enable libvirtd
virsh setmaxmem opnsense 7G --config virsh setmem opnsense 7G --config
GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0,115200n8 console=tty0 systemd.show_status=1"GRUB_TERMINAL="console serial"GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200"
sudo update-grub
sudo echo PermitRootLogin no >> /etc/ssh/sshd_config systemctrl restart sshd