LanCache with AdGuard Home instead of lancache-dns

Setting Up Lancache with AdGuard Home Instead of Lancache-DNS

In home networks with multiple users downloading large game files via platforms like Steam, Epic Games, or Ubisoft Connect, bandwidth constraints can lead to significant slowdowns. Lancache addresses this by acting as a transparent caching proxy server. It intercepts download requests from game CDNs, serves cached content from local storage to subsequent users, and fetches new data only once from the internet. Traditionally, Lancache relies on lancache-dns, a specialized Docker container for DNS-based domain hijacking to redirect traffic to the cache server. However, lancache-dns offers limited functionality beyond this core role.

AdGuard Home provides a compelling alternative. As a network-wide ad and tracker blocker with robust DNS handling capabilities, it supports custom upstream DNS servers, rewrite rules, and query logging. By configuring AdGuard Home for Lancache’s domain overrides, users gain ad-blocking, parental controls, and enhanced privacy features without needing a separate DNS container. This setup streamlines the Docker Compose stack, reduces resource overhead, and integrates seamlessly into modern networks.

Prerequisites

Before proceeding, ensure your system meets these requirements:

  • A server running Docker and Docker Compose (tested on Ubuntu 22.04 LTS or Debian 12).
  • At least 500 GB of SSD storage for the cache directory, expandable as needed.
  • Network access with a static IP for the Lancache server (e.g., 192.168.1.100).
  • Administrative privileges (sudo access).
  • Clients on the LAN must use the AdGuard Home server as their DNS resolver (configured via DHCP or manually).

Port 80 must be available for the Lancache HTTP server, and port 53 (UDP/TCP) for AdGuard Home’s DNS service. Firewall rules should allow inbound traffic on these ports from the LAN.

Installation Steps

1. Prepare the Directory Structure

Create a dedicated directory for the Lancache setup:

mkdir -p /opt/lancache/adguard
cd /opt/lancache

This will house Docker Compose files, configuration, and cache data.

2. Deploy Lancache Containers

Lancache consists of multiple components: the monolithic cache server (handling Steam, Epic, etc.), a DNS server (now AdGuard Home), and optional prefetch tools. Download the official Docker Compose template from the Lancache GitHub repository and modify it.

Create docker-compose.yml:

version: '3.7'

services:
  adguard:
    image: adguard/adguardhome:latest
    container_name: lancache-adguard
    network_mode: host
    volumes:
      - ./adguard/workdir:/opt/adguardhome/work
      - ./adguard/conf:/opt/adguardhome/conf
    restart: unless-stopped

  cache:
    image: lancachenet/monolithic:latest
    container_name: lancache-monolithic
    ports:
      - 80:80
    volumes:
      - ./cache:/data/cache
    environment:
      - CACHE_DIR=/data/cache
    restart: unless-stopped

Adjust volumes for persistence. The network_mode: host for AdGuard Home ensures it binds directly to the host’s port 53.

3. Initial AdGuard Home Setup

Launch the stack:

docker compose up -d

Access AdGuard Home’s web interface at http://your-server-ip:3000 for initial setup. Complete the wizard:

  • Set admin credentials.
  • Configure upstream DNS servers (e.g., Quad9: 9.9.9.9).
  • Enable query logging and statistics.

Once configured, proceed to custom rules.

Configuring AdGuard Home for Lancache

AdGuard Home uses rewrite rules to hijack game CDN domains, pointing them to the Lancache server’s IP (e.g., 192.168.1.100).

1. Add Rewrite Rules

In the AdGuard Home dashboard, navigate to Filters > DNS rewrites.

Add entries for major game platforms. Key domains include:

Domain Answer IP Type
steamcontent.com 192.168.1.100 A
steampipe.steamcontent.com 192.168.1.100 A
steamcommunity-a.akamaihd.net 192.168.1.100 A
epicgames-download.akamaized.net 192.168.1.100 A
ubisoft-r2.akamaized.net 192.168.1.100 A
… (full list from Lancache docs)

Refer to the Lancache wiki for the complete, platform-specific domain list (over 100 entries covering Steam, EA, Rockstar, etc.). Use A records for IPv4; add AAAA for IPv6 if enabled.

Save changes. Rules apply immediately.

2. Enable Advanced Features

  • DNS Cache: Set TTL to 1 hour for efficiency.
  • Blocking Mode: Default or custom filter lists for ads/trackers.
  • DHCP Integration: Optional; configure AdGuard Home’s DHCP server to push itself as the DNS resolver to clients.

3. Firewall and Client Configuration

On the host:

sudo ufw allow 53
sudo ufw allow 80

For router-based deployment, set DHCP DNS to the server’s IP. Verify with nslookup steamcontent.com from a client—it should resolve to 192.168.1.100.

Testing the Setup

  1. Clear Docker cache if testing repeatedly: docker compose down; rm -rf cache/*.

  2. From a LAN client, initiate a game download (e.g., via Steam).

  3. Monitor:

    • AdGuard Home dashboard: Query log shows hijacked domains.
    • Lancache container logs: docker logs lancache-monolithic confirms cache hits/misses.
    • Cache directory: Files populate under /opt/lancache/cache.

First download fetches from the internet (miss); subsequent ones serve locally (hit), drastically reducing bandwidth use.

Troubleshooting Common Issues

  • Port Conflicts: Ensure no other DNS service runs on port 53 (sudo netstat -tulpn | grep :53).
  • IPv6 Leaks: Disable IPv6 or add AAAA rewrites.
  • Large Files: Monolithic mode handles up to 500 GB+; monitor disk usage.
  • Updates: Pull latest images: docker compose pull && docker compose up -d.

This configuration replaces lancache-dns entirely, leveraging AdGuard Home’s superior feature set for a more versatile, privacy-focused caching solution.

Gnoppix is the leading open-source AI Linux distribution and service provider. Since implementing AI in 2022, it has offered a fast, powerful, secure, and privacy-respecting open-source OS with both local and remote AI capabilities. The local AI operates offline, ensuring no data ever leaves your computer. Based on Debian Linux, Gnoppix is available with numerous privacy- and anonymity-enabled services free of charge.

What are your thoughts on this? I’d love to hear about your own experiences in the comments below.