What is a DLNA media server good for?
Currently, the vast majority of routers with a USB port have a DLNA media server, this means that, if we connect an external hard drive or a pendrive, we can play multimedia content on any device that is connected to the home local network, without the need for do nothing else. However, it is possible that our router is not powerful enough to perform this task, especially since a lot of processor is used to read the movie or series that we are going to play, and, depending on the bitrate of the multimedia content, it may not be enough. For this reason, the most common is to use an external DLNA server, on any Linux-based server such as a Debian on a NAS, a Raspberry Pi or any device.
A DLNA server on a server with a Linux operating system will serve us for all this:
- It allows our TV to detect the server, and reproduce the content (audio, video and photos) that is on the server.
- Other devices such as smartphones, tablets and even our console could also detect it and play the content of the DLNA server via WiFi.
- We can connect other devices such as compatible speakers.
Logically, it is necessary that all devices have compatibility with the DLNA server that we are going to install.
DLNA servers that we can use
One of the most widely used DLNA servers is the popular miniDLNA, which is compatible with many operating systems and almost all devices. In our case, it is the one that has always given us the best result, although there are others like Fuppes that also work very well (integrated into the XigmaNAS NAS-oriented operating system). Other widely used DLNA servers is, for example, Plex Media Server, which not only incorporates Plex but also an integrated DLNA server for those TVs that are not compatible with your application.
The main characteristics of miniDLNA is that it is a DLNA server that consumes very few resources, both at the CPU and RAM level, everything will work really fast, and the CPU load will be the very action of reading the multimedia content of an external disk. This DLNA server can be installed on any Linux, regardless of the hardware, although logically we need it to be something powerful so as not to have any problems, and we must take into account its electricity consumption because it will be activated 24 hours a day. Other characteristics are that it has a really simple configuration, but a very important detail is that it does not allow audio and / or video transcoding, in this way, we must make sure that our TV supports the different video formats that exist.
In RedesZone we have been using miniDLNA for more than 5 years, and in all this time we have not had any problem when playing multimedia content, except in those old TVs that do not support the new video codecs such as H.265, but yes your TV is new (relatively) you shouldn’t have any problems. +
MiniDLNA installation and commissioning
The miniDLNA program is so well known that we have it available in the official repositories of the main GNU / Linux distributions, therefore, we will have it through the package manager. In this tutorial we have used Debian 10, but you can use any version such as Ubuntu, Linux Mint or any other distribution, because the operation in all of them is exactly the same.
The first thing we must do is install miniDLNA with all its dependencies:
sudo apt install minidlna
Once installed, we start the miniDLNA service:
sudo service minidlna start
Automatically, this service will start with the operating system, we do not have to do absolutely anything else, as you can see when we put:
sudo service minidlna status
Configure the miniDLNA server
This DLNA server is configured through a single configuration file that we will have to edit, therefore, it greatly facilitates its configuration and start-up, because we will not have to edit several, just one. To edit it, we will use any text editor, normally vim or nano is used, in our case, we will use nano.
sudo nano /etc/minidlna.conf
In the configuration file itself we will have all the necessary documentation to start up the DLNA server, but in RedesZone we will explain in detail how to configure it, since it comes in English. An important detail is that we have available a man page (manual) of the miniDLNA media server, therefore, we can obtain more information about the operation.
The first thing we have to learn is to load the sources of multimedia content, depending on whether we have video, audio or photographs, the syntax would be the following:
As you can see, if we want to load «A» is audio, P are photos, and V are videos, in this way, it will appear perfectly classified on TV. If we want videos and photographs to appear, we could also do it, ideal for cameras that also record video:
Another sentence that we must configure is where to store the DLNA database, in this case, it is done by uncommenting the following line:
The same happens with the directory of logs or registers, in case there is some kind of error:
The rest of the configuration options can be left in this way:
We have all the sentences already written in the configuration file, but they are commented, so we must uncomment them so that they are activated. Once we have configured it, we save the configuration file and proceed to perform a reboot of the DLNA server so that it applies the changes correctly.
sudo service minidlna restart
Once we have done all this, we can access our TV or smartphone and test the DLNA media server.
Configure Linux server firewall
On all Linux operating systems the firewall is always working, usually based on iptables, but we have an “allow all” by default, so you will not have to create any additional rules to access the DLNA media server. If you have configured the iptables firewall in restrictive mode with “deny all”, then you will have to introduce two rules for its correct operation.
iptables -A INPUT -p tcp --dport 8200 -j ACCEPT
iptables -A INPUT -p udp --dport 1900 -j ACCEPT
We assume that you have only one network interface and one subnet, in case you want to filter by port or subnet, you will have to add it, this rule is only to allow local access to the two ports defined above.
If you want these rules in the firewall to persist, you will have to execute the following command:
iptables-save > /etc/iptables/rules.v4
Now we can check if everything is working correctly with the DLNA client that we want, such as a TV, smartphone or tablet.
Check the status of the miniDLNA server
If we access our local IP address via the web or from any computer, and we put port 8200, we will access the miniDLNA status web interface. Here we will only see the media library, the number of audio, video and image files. We will also be able to see the clients currently connected to the DLNA media server, with their IP address, MAC address and the number of connections.
In our case, we have put:
Play the content of our DLNA server
Now that we have installed everything correctly, all we have to do is find the DLNA server on the local network. Depending on which client (device) you use, you will have to use a series of programs:
- TV: In all TVs, the recognition of DLNA media servers is totally automatic, it will appear in the upper or lower section where removable storage devices appear.
- Windows PC, Linux or MacOS: we can use KODI or VLC, the two best options for all platforms.
- Android: VLC or BubbleUPnP are two applications that will allow us to search for the DLNA server in the environment and play it.
- iOS: VLC
In all these programs, we must go to the “Network” section and look for an option such as UPnP or DLNA, and our newly configured DLNA server will automatically appear, if it does not appear on any device, we recommend checking the iptables firewall, and also if it is activated.
As you have seen, installing and configuring a DLNA server on our NAS or Linux server is really easy, we just have to install it and configure a text file that does not have much difficulty.