The rapid expansion of connected devices, industrial automation, and smart systems has made MQTT one of the most widely adopted communication protocols for modern IoT and Industry 4.0 environments. Whether you are a student, an engineer, or an IT professional preparing industrial laboratories and automation scenarios, building a solid and reproducible development environment is essential. That’s exactly where a clean VirtualBox installation of Debian 12 (“Bookworm”) combined with Mosquitto, the most popular open-source MQTT broker, becomes extremely valuable.
Running Debian inside a VirtualBox virtual machine provides an isolated and reliable sandbox where you can test IoT architectures, simulate devices, configure machine-to-machine communication, and reproduce real-life industrial scenarios without impacting your main operating system. This approach is especially useful for classroom labs, proof-of-concept prototypes, and cybersecurity-oriented experiments where controlling the entire environment is key.
Debian 12, released as the stable version of one of the world’s most trusted Linux distributions, brings long-term support, predictable updates, and excellent compatibility with IoT and industrial software stacks. Combined with Mosquitto, it becomes the ideal lightweight, stable, and secure environment to learn, develop, and test MQTT pipelines. Installing Mosquitto on a virtual machine also reflects best practices commonly used in professional and academic settings—especially in engineering schools, research labs, and Industry 4.0 ecosystems—where virtualization is standard.
In this guide, you will learn how to set up Debian 12 from scratch inside VirtualBox, configure the system properly, and install Mosquitto in a clean, step-by-step workflow. The goal is to make the installation process easy, reproducible, and ready for practical MQTT scenarios such as publishing sensor data, simulating a production line, or designing end-to-end IoT communication pipelines.
You will also benefit from precise instructions, tested commands, and recommendations based on hands-on field experience in industrial IoT deployments, teaching environments, and graduate-level research. Every step reflects real-world constraints: stable networking, resource allocation adapted to student machines, straightforward configuration for classroom use, and compatibility with MQTT tools like MQTT Explorer and MQTTX.
Whether you plan to use your virtual machine for academic teaching, an industrial prototype, or your own learning journey, this article will provide everything you need to begin with confidence. By the end, you will have a fully functional Debian 12 VM running Mosquitto as an MQTT broker, ready to communicate with publishers and subscribers—whether simulated or connected from physical devices like ESP32 microcontrollers, Raspberry Pi units, or PLC-driven automation systems.
This guide is designed as a practical, future-proof resource that you can reuse all year long for your labs, student workshops, and Industry 4.0 training sessions. Let’s get your Debian 12 + Mosquitto environment up and running.
1. Download VirtualBox & Debian 12 ISO
Step 1 — Download VirtualBox (latest version)
Go to the official VirtualBox website and download the version matching your operating system (Windows, macOS, or Linux).
Official link: virtualbox.org
Install VirtualBox using the default recommended settings.
Step 2 — Download Debian 12 “Bookworm” ISO
Visit the Debian official download page :
Official link: debian.org/distrib (for the latest stable release of Debian)
Official link: cdimage.debian.org/cdimage/archive/12.12.0/amd64/iso-cd (for the release 12.12 of Debian)
Download:
✔ Debian 12.12 netinst ISO (amd64) → recommended as of today 11/17/2025
Lightweight, fast, perfect for VM setups.
2. Create the Debian 12 Virtual Machine
Open VirtualBox → click New.
Use the following settings:
| Parameter | Recommended Value |
|---|---|
| Name | Debian12-Mosquitto |
| Type | GNU/Linux |
| Version | Debian (64-bit) |
| Memory (RAM) | 512 MB recommended for testing and educational purposes |
| Processors | 2 vCPUs |
| Network Adapters | Adapter 1: Intel PRO/1000 MT Desktop (Host-only Adapter, 'vboxnet0') ; Adapter 2: Intel PRO/1000 MT Desktop (NAT) ; |
| Disk size | 20 GB min • 40 GB recommended |
| Disk format | VDI |
| Storage | Dynamically allocated |
Attach the Debian ISO:
Settings → Storage → Empty Disk → Choose ISO → Select Debian 12 ISO
3. Install Debian 12 Inside VirtualBox
Start the VM → choose:
✔Graphical Install
Follow the installer:
Region & Language
- Language: English (recommended for tools)
- Location: Your country
- Keyboard: Your choice (FR for azerty keyboards for example, etc.)
Network
Domain: leave empty.
Users
Create a root password or leave it empty (sudo-based setup).
Create your main user account, then give it a password and confirm it.
Partitioning
Choose:
✔ Guided – Use entire disk
✔ All files in one partition.
Install the base system.
Software Selection
Select ONLY:
- SSH Server
- Standard System Utilities
Avoid Desktop Environment → keeps VM fast & lightweight.
Finish installation → reboot → remove ISO.
4. Update Debian 12 & Prepare for Mosquitto
Log in, then run:
sudo apt update
sudo apt upgrade -y
sudo apt install -y curl wget net-tools
Enable the firewall (optional but recommended) :
sudo apt install ufw -y
sudo ufw allow ssh
sudo ufw enable
5. Install Mosquitto on Debian 12
Mosquitto is available in the official Debian repos:
sudo apt install mosquitto mosquitto-clients -y
Enable service:
sudo systemctl enable mosquitto
sudo systemctl start mosquitto
Check status:
systemctl status mosquitto
You now have a running MQTT broker (^_-)
6. Open Ports for MQTT
Port MQTT → 1883 (TCP)
Add rule:
sudo ufw allow 1883/tcp
Confirm:
sudo ufw status
7. Test Your Mosquitto Broker (Local Test)
Open two terminals in Debian.
Terminal A — Subscriber:
mosquitto_sub -h localhost -t test/topic
Terminal B — Publisher:
mosquitto_pub -h localhost -t test/topic -m "Hello MQTT from Debian 12!"
If you see the message appear in Terminal A → broker works perfectly.
8. Test from Your Host Machine (Windows / Linux)
On your host computer, install:
- MQTT Explorer
- MQTTX
Then find Debian’s IP inside the VM:
ip a
Connect from MQTT Explorer using:
- Host: DEBIAN_VM_IP
- Port: 1883
- Protocol: MQTT 3.1.1 (recommended)
9. Create a Clean Snapshot (Important)
In VirtualBox:
Machine → Take Snapshot → “Fresh Debian 12 + Mosquitto”
This will help you reset your VM for every new lab or student session.
10. Conclusion
You now have a professional, reproducible, and lightweight environment running:
- Debian 12
- Mosquitto MQTT Broker
- Publisher/Subscriber tools
- Network-ready IoT lab simulation environment
Perfect for teaching MQTT, preparing Industry 4.0 labs, building ESP32/Raspberry Pi projects, and conducting research demos.



No comments:
Post a Comment