Skip to content

Instantly share code, notes, and snippets.

@mortn
Last active May 6, 2025 15:35
Show Gist options
  • Save mortn/05cefaa71d44b5d5df4c06876c19178e to your computer and use it in GitHub Desktop.
Save mortn/05cefaa71d44b5d5df4c06876c19178e to your computer and use it in GitHub Desktop.
HickoryDNS Podman Quadlet (rootless, yea baby!)
# .config/containers/systemd/hickorydns.container
[Container]
ContainerName=hickorydns
Image=docker.io/hickorydns/hickory-dns:latest
PublishPort=53:53/udp
UserNS=keep-id:uid=100,gid=100
Volume=%h/hickory/etc:/etc:ro
Volume=%h/hickory/zones:/var/named:ro
AutoUpdate=registry
AddCapability=NET_BIND_SERVICE
Pull=newer
[Install]
WantedBy=default.target
# .config/systemd/user/hickorydns.service
# Here you need to build/fetch the hickory-dns binary yourself.
[Unit]
Description=Hickory DNS Server
Documentation=https://github.com/hickory-dns/hickory-dns
After=network.target
[Service]
Type=simple
Environment="CONFIG=%h/hickory/etc/named.toml"
Environment="ZONES=%h/hickory/zones/"
ExecStart=%h/hickory/bin/hickory-dns -c ${CONFIG} -z ${ZONES}
Restart=on-failure
TimeoutStopSec=30
# Security options
ProtectSystem=full
ProtectHome=read-only
PrivateTmp=true
NoNewPrivileges=true
[Install]
WantedBy=default.target
@mortn
Copy link
Author

mortn commented May 6, 2025

Get HickoryDNS ❤️ up and running in a jiff on most Linux hosts!

NB! You only need one of these files! Either you run this as a quadlet (podman user space container) or as a systemd service

Podman quadlet quick start:

  1. Install Podman (v5.1+)
  2. Run loginctl enable-linger # This is to allow your processes to not just halt when you log off. NB!
  3. Install mkdir -p ~/.config/containers/systemd # Dir to hold all your awesome quadlets/user-space containers
  4. Create the .container file above into the dir
  5. echo 'net.ipv4.ip_unprivileged_port_start=53' | sudo tee /etc/sysctl.d/net.conf # Allow non-root users to expose ports on port 53 and upwards.

Setup HickoryDNS

  1. Create the directories ~/hickory/etc and ~/hickory/zones
  2. Write your named.toml config into the ~/hickory/etc
  3. Define your zones in ~/hickory/zones

Start the container (first time or new version will do an implicit pull):
systemctl --user start hickorydns

Debug with journalctl --user -fu hickorydns

Run systemctl --user daemon-reload if you change the hickorydns.container file

Blocklists

This config shows how to configure blocklists:
https://github.com/hickory-dns/hickory-dns/blob/main/tests/test-data/test_configs/chained_blocklist.toml

Fetch the blocklist you like from https://github.com/hagezi/dns-blocklists. For HickoryDNS you want the wildcard version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment