Limit Serviio Console access to LAN

NethServer Version: 7
Module: Firewall & Services

Hi all,

The Serviio Console page is accessible without a password, but the corresponding port needs to be opened to be able to access it from a client.
Since I don’t understand how this is supposed to be combined with other ports that need access from the Internet I created the following workaround, but I would like some guidelines how to do this in a clean way, because now I have a service that’s enabled but is only used for the green zone and never starts.

First I edited serviio-console.sh and placed the following code in it:

#!/bin/bash

####### Define your LAN IP prefix (adjust as needed)
LAN_PREFIX=“192.###.#.”

####### Get the IP address of the machine
CURRENT_IP=$(hostname -I | awk ‘{print $1}’)

####### Check if the current IP is within the LAN range
if [[ $CURRENT_IP == $LAN_PREFIX* ]]; then
if which xdg-open > /dev/null; then
xdg-open “https://localhost:2###3/console
elif which gnome-open > /dev/null; then
gnome-open “https://localhost:2###3/console
else
echo “No suitable command found to open the URL.”
exit 1
fi
else
echo “Serviio Console can only be accessed from within the LAN.”
exit 1
fi

After this I created the serviio-console.service with the following contents:

[Unit]
Description=Serviio Console Service
After=network.target

[Service]
Type=simple
ExecStart=/opt/serviio/bin/serviio-console.sh
Restart=on-failure

[Install]
WantedBy=multi-user.target

Then I added this service for the green zone only for the corresponding port, because without this last step the console is still accessible from an external source.

It works, because now I am able to access the console from my LAN and not from the Internet, but I would like some advice on how to fix this the way it supposed to.
The reason I don’t like it is because you can never start this service from the CLI, because it requires a graphical environment like a web browser.

Please advice,

misterjohn

PS.
For unknown reasons I am currently unable to add firewall rules for custom services.