How to Install OPNsense on Debian Latest

OPNsense is a FreeBSD-based open-source firewall and routing platform. In this tutorial, we will go through the process of installing OPNsense on Debian Latest.

Prerequisites

Before starting, you will need:

  • A server running Debian Latest.
  • A working internet connection.
  • Root access to the server.

Step 1 - Download OPNsense Image

  • Go to the OPNsense website and download the latest OPNsense image from https://opnsense.org/download/.
  • Choose the appropriate image for your architecture (i386 or amd64).

Step 2 - Install Required Packages

OPNsense requires some additional packages to be installed. To install the required packages, run the following command:

sudo apt update
sudo apt install qemu uml-utilities bridge-utils wget

Step 3 - Create a Bridge Network

OPNsense requires a virtual bridge network to function properly. To create a virtual bridge network, run the following command:

sudo brctl addbr opnbridge

Step 4 - Prepare Disk Image for OPNsense

  • Create a disk image for OPNsense using the following command:
qemu-img create -f qcow2 opnsense.qcow2 2G
  • Download the OPNsense image to the current directory using wget:
sudo wget https://opnsense.org/download/OPNsense-21.1.8-OpenSSL-vga-amd64.img.bz2
  • Decompress the image:
sudo bunzip2 OPNsense-21.1.8-OpenSSL-vga-amd64.img.bz2
  • Convert the image to the qcow2 format:
sudo qemu-img convert -O qcow2 OPNsense-21.1.8-OpenSSL-vga-amd64.img opnsense.qcow2
  • Resize the disk image to 10 GB:
sudo qemu-img resize opnsense.qcow2 +8G

Step 5 - Launch the OPNsense Image

Launch the OPNsense image with the following command:

sudo qemu-system-x86_64 -enable-kvm -m 1024 -smp 2 -netdev \
user,id=unet,hostfwd=tcp::2222-:22 -device \
virtio-net-pci,netdev=unet -device virtio-scsi \
-device scsi-hd,drive=opndisk \
-drive file=opnsense.qcow2,if=none,id=opndisk \
-device virtio-blk,drive=opndisk \
-netdev bridge,id=labbr,br=opnbridge \
-device virtio-net-pci,netdev=labbr

Step 6 - OPNsense Configuration

  • Once the VM is up and running, you will see the OPNsense console prompt.
  • Press 1 and hit Enter to start the installer.
  • Follow the prompts to complete the installation.
  • Once the installation is complete, reboot the system.
  • The OPNsense web interface will be available on https://your-server-ip.

Congratulations, you have successfully installed OPNsense on Debian Latest!