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.
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.
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!