Pi-Hole + GCP: How to create your own DNS Adblock Server

Anh Duong Viet
3 min readOct 10, 2019


In this article I’ll show you how to create your own DNS Adblock server using Pi-Hole. So what is pi-hole ?

Pi-hole is a DNS sinkhole that protects your devices from unwanted content, without installing any client-side software.


  • The article assumed you already have a Google Cloud Platform account and you already know how to use Compute Engine service.

Create Firewall Rule

You need create a new Firewall Rule. To create new Firewall Rule click the Menu on top left, click VPC Network and click Firewall Rules. Click Create Firewall Rule. This is configuration of the firewall rule:

  • Name: allow-dns
  • Target: All instances in the network
  • Source IP ranges:
  • Protocols and ports: udp:53;

Create Virtual Machine (VM) instance

Create your own VM server with this configuration (recommend)

  • vCPU: 1
  • Memory: 1 Gb
  • Disk size: 20 Gb
  • Disk image: Debian GNU/ Linux 9

Select Allow HTTP traffic in the Firewall section

Expand Management, Security, disks, networking, sole tenancy. In External IP section choose Create IP Address to Reserve a new static IP address.

Now you can ssh to server by click to SSH button or add your own SSH key to your server.

Install Pi-Hole

Follow the commands below to install pi-hole:

$ sudo apt update && sudo apt upgrade -y$ curl -sSL https://install.pi-hole.net | bash

At DNS Provider section. You can choose provider you want. In this article I choose Quad9 (filtered + ECS).

In Protocols section deselect IPv6

Choose OK for all the other prompts.

Change password for login the Web Interface with this command:

$ pihole -a -p

Login into the web interface using the External IP:


Click Settings, in DNS tab. Set your Interface Listening Behavior to Listen on All Interfaces

Now replace your DNS in your computer or mobile.

Good luck!



Anh Duong Viet

I’m a Software / DevOps engineer. My main is focus on maintain and maintain and ensure the stability of the infrastructure.