Host Lancache Docker on Synology Without Port Mapping

Hi Everyone, I want to show you a simple way to get a [partial] implementation of lancache going with docker containers on a synology NAS. This will alleviate the requirement of using a standalone piece of hardware to host your steam cache.

What is lancache, you ask? Lancache is a community developed tool for local caching of internet delivered games. In a more-or-less seamless way, it stores game install files on storage in the local network and serves up the stored copy the next time the game is installed to any pc on that network. This speeds up installs and reduces the overall data that gets downloaded IF games are going to be installed multiple times or to multiple computers. Lancache is an evolution of steamcache, and appears to handle more than just steam games. I haven’t had a chance to test it with anything else yet so ymmv.

In order to get this running with a minimalistic config we really need admin access to three things:

  • The Synology NAS
  • The routing table of the network default gateway
  • The DNS entries of the dhcp server

Synology Setup


First, setup the docker containers. Download these containers from the docker registry on the Synology NAS:

  • lancachenet/monolithic
  • lancachenet/lancache-dns

Launch the lancachenet/monolithic container with advanced settings

Under each tab - perform the specified action:

  • Advanced Settings - Check Enable Auto-Restart
  • Volume - Add Folder mapping(s) for the container “/data/cache” path and optionall for the “/data/logs” path.
  • Network - Assuming you have kept the default docker bridge network, ensure that is listed under Network Name
  • Port Settings - Remove both port forwards for 80 and 443 so that the list is empty. We aren’t mapping to the host ip so these are superfluous AND confusing.

lancache - monolithic volumes
lancache - monolithic network
lancache - monolithic portsettings

Don’t change anything else and launch it. To get it’s ip address; open details, select the terminal tab, create a new /bin/bash, you should see a bash prompt. Now run ip addr. Mine landed on 172.17.0.3.

Launch the lancachenet/lancache-dns container with advanced settings

Make sure Advanced Settings, Network and Port Settings are the same as as for the monolithic container. No need for any Volumes here.

Under Environment add the variable LANCACHE_IP and set the value to the ip address picked up by the monolithic container.
lancache - dns environment

Once it’s launched, get it’s ip address. It appears to be based on an older container, and ip isn’t available so use ifconfig.

Router Setup

Add a new route on the default gateway informing the router that any traffic to 172.17.0.0/16 network must go through the Synology. I’m using a pfsense router, when requires the extra step of adding a new gateway.
Under the system->routing just Add a new gateway on the LAN interface, using the ip address of your synology with a name you remember.

Then, under the static routes tab, create the route using that gateway for the 172.17.0.0/16 subnet.

Your routing table should look something like this.

DHCP DNS server

So now we want all clients on the network to use the new dns server so it directs all steam requests to the lancache server. PfSense is also my DHCP server and this a super straightforward change to make. In my case, the lancache-dns ip is 172.17.0.2.

Wrap-Up

At this point, all you should need to do is refresh/renew your ip address to get the updated dns ip entry. It’s possible something isn’t working quite right, so if something is broken, just set your DHCP DNS server ip back to a real DNS server, 8.8.8.8, 1.1.1.1 and 75.75.75.75 should all work equally well.

Now any machine on the network that gets a dhcp address will automatically be instructed to use the lancache-dns for all dns queries. This has potential for badness that I’m not too concerned about right now. If I were to make this better, I would create a separate vlan for gaming computers, and only they would get the alternate DNS server ip.

Every docker instance on the docker bridge is now accessible to any machine on my network. I like it, but if i want private docker containers, I could just create a new docker bridge, that didn’t have a route into it.

There is some discussion of other game services requiring https connections, which need to be “SNI proxied” for which there is another lancache docker container, however, the way this is setup, it doesn’t have a provision for the SNI proxy container and the monolithic container to have separate ip addresses. Which all docker containers on this bridge will. So I haven’t thought too hard about solving that problem. I think it would involve updating the docker-compose file for the monolithic container so that nginx can point proxy port 443 queries to another ip address.

After following these instructions, you too can have your synology NAS host a steam cache. No extra hardware required!

Cheers!

1 Like

The problem with using the internal docker network IPs is that each container is not guaranteed to have the same IP every single time they start since it depends on start up order.

Oh yeah, I forgot to mention that, it seems like there should be a way to set them statically.

If you create the docker network beforehand, you can specify the IP of the container. IDK how much granularity Synology gives you in that realm though since I have never used one.

So the “bridge” network was setup be default when I installed docker on the NAS. Can you show a way to specify the ip of the container in a docker run command?

Erm, but what you describe below is exactly “using standalone piece of hardware”…
Synology stuff grows on trees or something? :wink:

To claim no need for extra hardware except gaming rigs, you would need to install those lancache dockers on one of the gaming machines.
Probably 10-12c one, so one can still play on it, while others download. But 8c would do in a pinch I suppose.

Other than that good guide, I didn’t know there are prebuilt docker images for caching steam :slight_smile:
As for static IP, probably something like that:

docker network create --subnet=172.18.0.0/16 mysub
docker run --net mysub --ip 172.18.0.22 lancache bash

In other news, this DOES seem to break the install of the Battle.net launcher.

The launcher gave me this inscrutable error. I tried a lot of things with Lutris before finally forcing a real-world DNS, which allowed the install to complete. I can’t remember now what the URL that couldn’t be reached was, something short like dl.battle.net, maybe? But I had to watch the command-line output of Lutris during the install of JUST the battle.net client to figure that one out. Anyway, once the launcher is successfully installed, everything else with play of Diablo III is working fine with the lancache DNS server.

Thanks!

For me the problem is that the lancache images are built with the assumption that they all share the same ip address. And it’s a real trick to add a virtual interface to the [insert your server designation here - synology in my case] AND separate it from the built-in webserver. I was not looking forward to trying to make that persistent.

On the subject of persistence, I think to really trust this setup to survive a reboot, the docker containers need to be launched with that --ip command, and I think that needs to be done from the command line.

I hate being that guy, but what about IPv6?

I’d post how to do it, but I’m in the middle of some work and I don’t own a Synology.

I would love to understand ip6 well enough to setup a network with it. But, alas, I don’t know how to use it.

I find may things about ip6 mystifying, but what kept me from using it is the specific problem of how to reconcile my network with networks that don’t use ip6. A specific problem is the need to disable ip6 in order to update/upgrade from ubuntu repositories.

I entered everything according to your templates. Except for the IP address. Both servers are running, logs are written but nothing in the data/cache directory. Do I have to give special permissions in Synology.?

Have you tried integrating autofill with this?

Please HELP ME OUT lancache/lancache-dns NOT WORKING.