Getting older, not necessarily wiser!
In a continuation from the last post, we will build a UPnP (Universal Plug and Play) media server that can drive smart devices directly. In this type of setup, the UPnP server provides an automated network connection directly to our smart devices.
For this use case we will be revisiting the series of posts on a base Debian install. Also of note, this is not going to be the most secure install, so you will never want to expose this type of server to the internet.
While this type of server does work, the way the user is created can cause some other issues. Before trying this build you may want to wait for my next post on using secure copy, as it might save you some trouble with this server.
About UPnP
To put it simply, the UPnP protocol allows device to device networking. It supports what is referred to as zero configuration networking. Any UPnP enabled device can scan a network and dynamically set up a connection with any UPnP server it finds.
While this all sounds great, it means the protocol is extremely noisy, and can have all sorts of inherent security risks. This makes it unsuitable for deployment in larger public networks. On smaller closed home networks it works well.
Digital Living Network Alliance (DLNA) is a term heard in conjugation with UPnP. The DLNA published guides on home networking interoperability. I mention it here because it will come up shortly.
For my UPnP server I am using a ten year old second generation NUC with a i5-3427U processor. You do not really need a lot of power for this type of server. I like the NUC because it is low power, about 17 watts. Compare this to re-purposing an old desktop computer, that can draw 200 plus watts. This can add up over time for a computer that is running 24/7.
This will be a base Debian setup as described in this series of posts. I am using Debian because this is a server and I want the stability.
I backed up in the installer at the Host Name prompt so I could configure the network manually. Since this is a server, it should have a fixed IP address, rather than getting one assigned by the DHCP server in your router.
I used the guided partitioning option with everything in one partition for this proof of concept run. If I decide to set one of these up permanently, I will use a larger second hard drive setup to its own mount point (maybe a separate user home directory or possibly /srv or /opt).
At the end of the install I select SSH server and common utilities from tasksel, making sure to un-mark Desktop and Gnome.
At this point, once the initial install was done, I disconnected the keyboard and monitor. Then logged in with SSH (I am using the PuTTY SSH client program). Because openssh wonβt let you log in as root initially, you will have to do an su to become root (I suggest using the -l option to load the root environment, like the path variable).
su -l root
As long as you are logged in, you can check your ip address with the following command.
ip a
If it is not correct you can edit the /etc/network/interfaces file to fix it.
Once logged in as root, use apt to install minidlna.
apt install minidlna
The minidlna server package will pull down several dependencies, mostly libraries.
Before doing anything further, there are a few things I need to check, after reading the man page. Some items mentioned in the man page suggest a minidlna user. So I issue the following commands to check on this.
cat /etc/passwd |grep minidlna cat /etc/group |grep minidlna
In both cases I find that the minidlna install created both a user and a group. This is useful knowledge for setup, and I wish it was made a little clearer during the install (unless I just missed it).
The next place we want to go is /etc/default/minidlna. Here we will find the user and group. We want to un-comment these entries (remove the β#β from the start of the line). You can also setup logging in this file if you want. Save and close this file.
Next we want to edit the /etc/minidlna.conf file. The file is very well commented, so easy to modify. The first thing we do is activate the user. However the file states that our previous file overrides this entry. I went ahead and uncommitted it, as the text says that minidlna runs as root by default.
Next we need to setup some media directories. Read the comments in the file for information on doing this. Because there is a minidlna user and group I created a home directory to put media files in, and assigned minidlna as user and group. For example, A music directory.
mkdir /home/minidlna mkdir /home/minidlna/music chown -R minidlna:minidlna /home/minidlna
Then in the /etc/minidlna.conf file I add the following.
media_dir=A,/home/minidlna/music/
You can look through the /etc/minidlna.conf file for other options like port, log files, album art cache, etc. Set these up per your own needs. For example, friendly_name=<my server name>. Also feel free to add additional media directories.
Once finished, save and exit the file.
All that is left at this point is to copy some media files to your directories, and make sure they have minidlna as both user and group. I used a USB stick to copy some media files to this server.
Note that minidlna will recursively scan the directories you chose at regular intervals and at startup to pick up any new files
Since we have changed some configuration files, we need to restart the minidlna server for our changes to take effect. You can either restart the computer, or use the following command.
systemctl restart minidlna
You can check the status with this command.
systemctl status minidlna
If the minidlna service is not running you can start it, and enable it to run at boot time with then following two commands.
systemctl enable minidlna systemctl start minidlna
For another test, open a browser on a different computer and point it at your server and port 8200. For example, our media server is at 192.158.10.10, then you would point your browser at 192.168.190.10:8200. This should bring up a minidlna statistics page with the number and type of files, as well as number and types of connections.
I am using a Samsung Smart TV in the family room, that is part of my LAN for for various streaming services. Going to the source section I see a new one has been added with my server name and the Debian logo. You may need to restart the TV to get the server to show up.
I select this source, and I go to a file browser where I can see all the media files I placed on the server. I select one and it plays.
Going back to the server web interface (192.168.10.10:8200) and refreshing, I can see a new client has been added; Samsung Series.
Once setup is done, it is pretty much automatic. Going to another smart TV, in the bedroom, I turn it on and find my server under sources.
In this post we setup a UPnP streaming server that can be used with most smart devices. It is not really fancy, but it does work and has very low overhead and hardware requirements.
In the next post in this series, we will look at upping the game with some more robust software.
Part 1 Media Servers and Clients
Part 2 Universal Plug and Play (UPnP) Server
Part 3 Using Secure Copy Protocol (scp) on a Server
Part 4 File Transfer Protocol (FTP) Server Build
Add New Comment