brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: write your own ufw application profile in /etc/ufw/applications.d

Ufw
~/tips/tip-ufw-custom-app-profile

[Jellyfin]

Defines a named profile for your own service so rules refer to a name.

Profiles like OpenSSH or Nginx Full come with packages. For a service that doesn’t ship one, you can write the file yourself and get the same readable rules.

Profiles are small INI files in /etc/ufw/applications.d/. A file called jellyfin:

[Jellyfin]
title=Jellyfin media server
description=Web interface over HTTP and HTTPS
ports=8096,8920/tcp

Then check that ufw reads it, and use it:

sudo ufw app info Jellyfin
sudo ufw allow from 192.0.2.0/24 to any app Jellyfin

ufw status now shows Jellyfin instead of a pair of port numbers. I find a rule list like that much easier to read months later.

The real payoff comes when ports change. Edit the ports= line, then run:

sudo ufw app update Jellyfin

Every rule that uses the profile is updated in one go, so you don’t hunt down old port numbers.

Mind the format. Like on the command line, a list of ports needs a protocol, and several port and protocol pairs are separated with |, as in ports=8096/tcp|7359/udp. A mistake in the file makes ufw app list complain about it. Keep your own profiles in files with their own names, since package updates can replace the profiles that came with a package.

Further reading: ufw(8) manual page

More Ufw tips sudo ufw app update all sudo ufw show raw sudo ufw allow to 10.0.0.1 proto esp sudo ufw allow to 224.0.0.0/24 from 10.0.0.1 proto vrrp sudo ufw show listening All Ufw tips (32) All topics

Link