How to disable completly firewall in Nethserver NG 7 (Madsonic uPnP/DLNA)

I have a VM with Nethserver NG 7 installed at my home.
The VM is a guest in a NEthserver NG 6.9 installation.

In the VM i have installed madsonic,
I have opened port 4040 in the firewall with the command

config set fw_madsonic service status enabled TCPPort 4040 access green
signal-event firewall-adjust

and I successfully connect via web or phone app to my music library.

Now, I woult like to try the DLNA/UPnP service of madsonic but, when I activate the service, I don’t see the DLNA server in my network.

I read this document but I’m not able to implement it.

I would like to disable completly iptables/shorewall in my VM but if I try with

service shorewall stop

It seems that all port are blocked: for example I can’t able to open the madsonic webserver at port 4040.

Some hints?

Thank you.

Can you reproduce your issue with the module I did : nethserver-madsonic

See the wiki to install it

I’d go with @stephdl package.

But if you’re still trying to disable the firewall, you’re looking for this command:

shorewall clear

perfetct, with

shorewall clear

UPnP/DLNA works

(Madsonic has a tag/folders management that’s a very mess… It driving me crazy!)

It would be better to find what is the ports and the protocol used and allow them in the firewall.

Once find I could allow them in my module !

1 Like

I read a bit around and it seemst tha dlna uses port 1900 udp but madsonic open ports of dlna servicer randomly at every startup.
I Tried to poen ports 1900/UDP and 2869/TCP but without luck…

It worths to ask a question on the madsonic forum :smirk:

Edit: in another hand, if the port is really random, it will complicate the work…the only manner is to implement upnp in shorewall and it is a hole in the wall.

I think that UPNP is another way to say “please dig an large and uncontrolled hole into my rules”.
Sometimes i find appliances with this setting enabled as default. And i switch this immediately off.


I agree with @pike

My installation is on a VM (Nethserver NG 7.3) inside a Nethserver NG 6.9 configured as server only (no gateway/firewall).

My routers have PnP disabled and forward only the strictly necessary ports (remapped on non standard ports).

I would like serve Madsonic DLNA only in my home lan network so I think I can disable shorewall safely, but I would like to have a configuration with shorewall up…

@stephdl: Topics about uPnP/DLA seem bit taboo on madsonic forum:

Next step will be try Madsonic with Sonos speakers (when I will buy them…)

Madsonic is a clone of subsonic, you should search also with subsonic by google

question directed to the developer of madsonic for the dedicated port of dlna

1 Like

Just a google search, these are on the first page. Never disable the firewall, thats half the point of Nethserver. If you dont want a firewall, use freenas and madsonic/subsonic plugin or even run a docker server. I have no problem accessing my madsonic when I portforward to the host “madsonic”. Try opening up just the port you need for madsonic and see if that works.

I already have opened port 4040 (It’s the first thing that I have made):

config set fw_madsonic service status enabled TCPPort 4040 access green
signal-event firewall-adjust

In the links you have reported I don’t find the section where are signed the ports that I have to open to make uPnP/DLNA available to my network.

I think we have to wait…
Played around with madsonic and without “shorewall clear” I could not reach my music files.
Opened all ports I found by netstatting and even if port 4040 tcp or 1900(DLNA) udp was open it still didn’t work.


What about alternatives (ampache, ushare, mediatomb…etc)?

did you use nethserver-madsonic ???

what was wrong, can you see the web interface at /yoururl/madsonic ?

1 Like

Yes, I meant I just could not use DLNA. The web ui works like a charm with enabled firewall.

This was too general… :slight_smile:

something already asked


I can’t wait… :slight_smile: The goal is to open the right random port so I used netstat to find out, which ports are open for madsonic:
[root@server ~]# netstat -tlpn | grep 4040 tcp6 0 0 :::4040 :::* LISTEN 5267/java [root@server ~]# netstat -tlpn | grep 5267 tcp6 0 0 :::4040 :::* LISTEN 5267/java tcp6 0 0 :::* LISTEN 5267/java tcp6 0 0 :::37153 :::* LISTEN 5267/java tcp6 0 0 :::9412 :::* LISTEN 5267/java
The port 39277, the only one which is bound to an IP is the needed one, but the problem is:

So I tried to script it. The following commands worked on 2 of my Nethservers:
config set madsonic service MaxMemory 512 Name madsonic TCPPorts 4040,$(echo $(netstat -tlpn | grep $(netstat -tlpn | grep 4040 | cut -c 80-84 | awk '{$1=$1};1') | cut -d "." -f 4 | cut -d ":" -f 2)) UDPPort 1900 access green status enabled webaccess private signal-event firewall-adjust

My thoughts:
Madsonic is a java process, there may be more, so I get the correct madsonic PID out of netstat when searching for 4040.
With the PID I grep the lines, to have the open madsonic ports and echo puts them in one line.
Then I cut the 4th field with point as delimiter, which is the last number of the ip inclusive “:” and port. So just cut it with “:” and the second field is the port to open…

If it fails just run the next 2 lines to get back to the default settings for madsonic service:
config set madsonic service MaxMemory 512 Name madsonic TCPPort 4040 access green status enabled webaccess private signal-event firewall-adjust
When you start/restart madsonic your have to wait about 10 seconds, until madsonic fully comes up before you can run the command.
Worked with my LG TV and with VLC on Android…


I did something similar for transmission to catch the random tcp port, thank for make it available

1 Like

could be also done by grep and sed

netstat -tlpn | grep $(cat /var/run/ | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b:[0-9]+" | sed 's/[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}://g'

1 Like