This guide explains how to configure a Debian server as a virtual Network UPS Tools (NUT) server. This setup is ideal for situations where a physical UPS provides battery backup but lacks a data port for monitoring.
The server will simulate a real UPS, and its status (e.g., "On Battery," "Online") can be controlled by an external script. This allows network clients (like Synology NAS, Proxmox hosts, or Windows machines) to connect to it and perform a graceful shutdown during a power failure.
Install the core NUT server package from the Debian repositories.
sudo apt update
sudo apt install nut-server -y
The following files in /etc/nut/
must be edited to create and expose the virtual UPS.
nut.conf
This file sets the operating mode for NUT. For serving clients over the network, netserver
is the correct mode.
/etc/nut/nut.conf
MODE=netserver
ups.conf
Here, we define our "fake" UPS using the dummy-ups
driver. The state of this UPS is controlled by the content of the file specified in the port
directive.
/etc/nut/ups.conf
# A global setting for retrying connections
maxretry = 3
# Definition of our virtual UPS, named "ups"
[ups]
driver = dummy-ups
port = /var/run/nut/virtual.device
desc = "Virtual UPS for power monitoring"
user = nut
upsd.users
Define the username and password that client machines will use to connect to this NUT server.
/etc/nut/upsd.users
[monuser]
password = secret
upsmon slave
Note: For security, change the password
from "secret" to a strong, unique password.upsd.conf
This file controls which network interfaces the NUT server listens on.
/etc/nut/upsd.conf
# Listen on all available network interfaces (IPv4) on the default port
LISTEN 0.0.0.0 3493
Note on Security: For a more secure setup, you can replace LISTEN 0.0.0.0
with specific LISTEN
directives for each IP the server should be accessible from (e.g., LISTEN 127.0.0.1
and LISTEN 192.168.2.118
).On a fresh installation, the dummy-ups
driver will fail to start if its runtime directory or state file do not exist. The error will look like this:
Can't open dummy-ups definition file /var/run/nut/virtual.device: No such file or directory
To test immediately, manually create both the directory and the empty state file, then set their ownership.
# Create the directory
sudo mkdir -p /var/run/nut
# Create the empty state file
sudo touch /var/run/nut/virtual.device
# Set the correct owner for both
sudo chown -R nut:nut /var/run/nut
The /var/run
directory is cleared on reboot. To ensure the directory and file are always present at startup, create a tmpfiles.d
configuration. This is the most robust solution.
sudo nano /etc/tmpfiles.d/nut.conf
d /var/run/nut 0755 nut nut -
f /var/run/nut/virtual.device 0664 nut nut -
Now you can start and test the NUT services.
Start the UPS driver:
sudo upsdrvctl start
Note: It is normal to see a Duplicate driver instance detected
message if you run this command more than once. This is not an error.
Start and enable the main NUT server:
sudo systemctl start nut-server.service
sudo systemctl enable nut-server.service
Verify the status:
Check the status of your virtual UPS. The command should return a list of variables.
upsc ups@localhost
Look for the key ups.status
. By default, it should be OL
(Online).
...
ups.status: OL
...
Note: Harmless messages like Could not find PID file
may appear on the first start and can be safely ignored.
The power status is controlled by writing to the state file defined in ups.conf
. This is how your external monitoring script will interact with NUT.
To simulate a power failure (low battery):
echo "ups.status: OB LB" | sudo tee /var/run/nut/virtual.device
OB
= On BatteryLB
= Low BatteryTo simulate power restoration:
echo "ups.status: OL" | sudo tee /var/run/nut/virtual.device
OL
= OnlineYour virtual NUT server is now fully configured and ready to be controlled by your automation scripts.