Skip to content

Instantly share code, notes, and snippets.

@Riebart
Created July 15, 2019 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Riebart/e76df1baef87f4041867ec3a0874ee7b to your computer and use it in GitHub Desktop.
Save Riebart/e76df1baef87f4041867ec3a0874ee7b to your computer and use it in GitHub Desktop.
Start a PiHole docker container with the appropriate upstream DNS and server IPs autodetected.
#!/bin/bash
docker run --rm -d --name pihole \
-p 53:53/tcp -p 53:53/udp -p 80:80 \
-v /home/pihole/etc/pihole:/etc/pihole/ \
-v /home/pihole/etc/dnsmasq.d:/etc/dnsmasq.d/ \
--dns $(nslookup 1.1.1.1 | \
grep Server: | tr -s '\t' | \
cut -f2) \
-e DNS1=$(nslookup 1.1.1.1 | \
grep Server: | tr -s '\t' | cut -f2) \
-e DNS2=no \
-e ServerIP=$(ip route list | \
grep "^default" | cut -d ' ' -f7,9 | sort -t ' ' -k2 | \
head -n1 | cut -d ' ' -f1) \
pihole/pihole:latest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment