Kodi server

Powered by Drupal

Kodi logo I've spent quite a while recently configuring Kodi on an Intel NUC running Ubuntu that lives behind my TV. I needed this box to:

  • Run a recent version of Kodi on a general purpose Linux OS (I chose Ubuntu server)
  • Load Kodi without any login/password prompt when the device boots
  • Make the media database accessible to other instances of Kodi on the local network
  • Make the actual media files accessible to other computers on the local network, using a fast protocol
  • Automatically mount known hard drives containing media files at consistent mount points (using udev)
  • Allow remote login and administration via SSH
  • Run a "headless" torrent client (transmission) that can be controlled via SSH
  • Run an always-on VPN client connection for torrent traffic

I couldn't find any guides that showed how to bring all of those things together, so I wrote this guide. Since it's likely that some people will need some but not all of the functionality, I've broken the tutorial into sections to make for easier reading. Some sections show you how to achieve things that could be useful on other projects. I'm running Ubuntu server on an Intel NUC, but you could probably use this guide to set up Kodi on a Raspberry Pi.

Kodi installation & configuration

The first part of the tutorial deals with basic Kodi installation and network configuration for the server. It sets out some basic configuration to get the system to load Kodi straight away when it boots up, make the media database available to other Kodi clients on the network, enabling the power menu within Kodi's interface, and making sure automatic updates are enabled.

Making media files available on your network with NFS

The second part of the tutorial concerns the use of the Network File System (NFS) protocol for sharing files on your network. NFS is extremely fast compared to other file sharing protocols, which makes it ideal for sharing media files on the LAN.

Auto-mounting external hard drives

The third part of the tutorial sets out a few different methods I've tried for automounting known external hard drives, and the working solution I arrived at. My hard drives contain the media files in my library, so I need them to be mounted at consistent locations to avoid breaking Kodi's file indexing and the NFS shares.

Remote login with SSH

This section contains some tips on how to enable remote login and administration with SSH, and some ways to secure it against abuse.

Transmission torrent client

Transmission is an ideal torrent client for use as a background daemon because it has such good commandline support, allowing it to be controlled remotely via SSH. This section covers its installation and configuration, and some tips for controlling it using the commandline as well as enabling administration on the local network using the web interface.

Always on VPN connection

This section covers configuration of an openvpn client connection to an external server, to anonymise traffic to and from the Kodi box and prevent bandwidth throttling of torrent traffic by your ISP. You will also find some additional configuration to ensure the VPN does not break secure SSH connections from the public internet via your router, and some scripts to make sure Transmission binds to the local IP address of the VPN interface (so it doesn't try to send traffic out over your public connection if the VPN goes down).

Firewall

The final section deals with firewall configuration. Here you will find Uncomplicated Fire Wall (UFW) and iptables rules to prevent transmission from sending traffic using your normal wifi interface, as well as a few extra rules to secure the server against traffic from the VPN side. If you have any questions about this tutorial, please leave a comment on the relevant section and I'll do my best to help!