Skip to the content.

Guide for Oracle Cloud to setup PiVPN + Pihole

1. Prerequisite

2. Install Ubuntu in Oracle cloud

3. Install PiVPN

sudo su - root
curl -L https://install.pivpn.io | bash

3a. Choose OpenVPN

3b. Choose WireGuard

After finished, reboot the instance to let tun0 or wg0 show up when setup pihole.

sudo reboot

4. Install Pihole

Copy these commands in terminal.

sudo su - root
curl -sSL https://install.pi-hole.net | bash

Make sure choose tun0 or wg0. Everything else should be similar to the last post

5. Setup OpenVPN to run with Pihole

Copy these commands in terminal.

sudo su - root
curl -L https://install.pivpn.io | bash

5a. Only for OpenVPN (optional)

6. Allow port in iptables

By default, the OS doesn’t allow tun0 interface. We need tun0 to allow openvpn and pihole work. More information

6a. OpenVPN

sudo su - root
iptables -I INPUT -i tun0 -m comment --comment "# enable tun0 for pihole #" -j ACCEPT
iptables-save > /etc/iptables/rules.v4

6b. WireGuard

sudo su - root
iptables -I INPUT -i wg0 -m comment --comment "# enable wg0 for pihole #" -j ACCEPT
iptables-save > /etc/iptables/rules.v4

7. Access web page on Internet [Optional]

Run ip addr to check interface ens3 or enp0s3

Then Replace interface name to xxxx

Need to allow port 80 in iptables

iptables -I INPUT -i xxxx -p tcp --dport 80 -m comment --comment "# http #" -j ACCEPT

8. Setup DDNS [Optinal]

I use dynu.com. IP Update Protocol

Password should be MD5/SHA-256 hash

wget "https://api.dynu.com/nic/update?hostname=example.com&password=098f6bcd4621d373cade4e832627b4f6" -O /dev/null

9. Create LetsEncrypt for DDNS [Optional]

Setup acme for auto renew LetsEncrypt certificate.

git clone https://github.com/acmesh-official/acme.sh.git
cd ./acme.sh
./acme.sh --install -m your@email.com

Follow this guide to get client_id and secret. Then replace in commands

export Dynu_ClientId="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
export Dynu_Secret="yyyyyyyyyyyyyyyyyyyyyyyyy"
acme.sh --issue --dns dns_dynu -d example.com -d www.example.com

10. WireGuard Allow Local Access [Optional]

https://techjourney.net/how-to-allow-local-network-when-using-wireguard-vpn-tunnel-in-windows-10/

Change AllowedIPs = 0.0.0.0/0, ::/0

To:

AllowedIPs = 0.0.0.0/1, 128.0.0.0/1, ::/1, 8000::/1

Previous - Raspberrypi 3 to setup Openvpn + Pihole + DNS-over-HTTPS