Setup pi-hole ad filter server on AWS in 2 minutes
We assume you have an AWS account (if not get one here https://aws.amazon.com/) and you know the basics on how to start an instance in AWS (https://aws.amazon.com/ec2/spot/spot-getting-started/).
- Start an AWS server type in the region of your choice (they start at US$1 per month for spot instances. I use T3A.NANO or T4G.NANO)
- Open the right ports in the AWS security group (TCP 80, 53, 443, 4711 and UDP 53 at least for an IPv4 server). Of course only for your own IP addresses. DO NOT OPEN THE SERVER FOR ALL. YOUR MACHINE WILL BE ADBUSED VERY QUICKLY. (Some more info)
- Use OS: Ubuntu 24.04 LTS
- Assign fixed IP address (Elastic IP)
- Log into the command line interface of your new server
- Update with
apt -y update && apt -y upgrade && reboot - Run some helpful commands:
apt install -y net-tools mc fail2ban unboundhostnamectl set-hostname [some FQ hostname you want your server to be] - Run
curl -sSL https://install.pi-hole.net | bash - Follow the guided installation process. Suggested settings are fine. Although I disable IPv6, because I don’t want to use it.
- Take note of the admin password or change it with
pihole setpassword reboot- Ready to go
- Assign the fixed public IP address to your computers as a DNS server and enjoy browsing with less ads (you can tweak pihole so it is even better at blocking the right stuff, but this is not a subject for this quick guide. Read https://pi-hole.net/ )
The following is optional. You don’t need it, but I like to use my own caching name server. So I don’t have to use the public DNS servers. Reasoning for this is another discussion and I will not cover here. (see https://docs.pi-hole.net/guides/dns/unbound/ under “caching”)
- Install the DNS server on your pihole server
apt install unbound -y - Edit unbound configuration
vim /etc/unbound/unbound.conf.d/pi-hole.conf
A new file is created. Put the following into it:server:
verbosity: 0interface: 127.0.0.1
port: 6236do-ip4: yes
do-udp: yes
do-tcp: yes
do-ip6: no
prefer-ip6: no# Uncomment and update root hints file regularly
root-hints: /var/lib/unbound/root.hintsharden-glue: yes
harden-dnssec-stripped: yes
use-caps-for-id: noedns-buffer-size: 1232 # ← Changed to avoid fragmentation with DNSSEC
prefetch: yes
prefetch-key: yes # ← Helps speed up DNSSEC lookupsnum-threads: 2 # ← If you have at least 2 cores
so-rcvbuf: 4m # ← Larger buffer can help in bursts
cache-min-ttl: 60 # ← Avoids repeated resolution of short TTL domains
cache-max-ttl: 86400 # ← Reasonable upper bound for non-critical domainsmsg-cache-size: 64m # ← Increase if you have memory (default is 4m)
rrset-cache-size: 128m # ← Increase for large cachingminimal-responses: yes # ← Don’t send extra data to clients
qname-minimisation: yes
qname-minimisation-strict: noprivate-address: 192.168.0.0/16
private-address: 169.254.0.0/16
private-address: 172.16.0.0/12
private-address: 10.0.0.0/8
private-address: fd00::/8
private-address: fe80::/10
- Make Named/Bind start automatically
systemctl enable --now unbound - Update the root hints file (it speeds up look ups):
wget -O /var/lib/unbound/root.hints https://www.internic.net/domain/named.cache
chown unbound:unbound /var/lib/unbound/root.hints
chmod 644 /var/lib/unbound/root.hints - reboot
- Then log into the admin interface and go to Settings / DNS and add this:

Disable the other public DNS services. So you only use your own Caching DNS and click save. - Ready to go.
- If you have a backup from a previous installation you can now go to the GUI / Settings / Teleporter and upload the backup file. I would also reboot after restoring the backup.
And even more optional is the setup of a swap file, if you chose a server with little RAM.
These instructions are very good.
https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-20-04
Adding more DNS lists to get a higher degree of blocking, but also the chance to block stuff you may want I add these lists in “Group Management / Adlists” in the Pi-hole GUI:
https://adaway.org/hosts.txt
https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt
https://www.technoy.de/lists/blocklist.txt
There are more lists to be found here:
https://firebog.net/
https://www.technoy.de/lists/blocklists-fuer-pihole/ (in German, but very good)
Remember after adding blocklists you need to update Gravity in “Tools/Update Gravity” in the GUI. Otherwise the list will not be used.
MAINTANANCE
From time to time you should run the following from the command line to keep everything up-to-date
pihole -up&& apt update -y && apt upgrade -y && apt -y full-upgrade && apt -y autoremove && apt -y autoremove --purge
BACKUP
You should backup your configuration of pi-hole. So you won’t loose all your hard work in case your server crashes. I do this because I am using AWS spot (Android/ARCH) instances, which are extremely cheap, but AWS can close/terminate them when demand is high on their servers. Backup will help you get back up and running quickly.
GUI: Settings/Teleporter