How to install Pi-Hole on Docker and Synology with MacVlan + Auto Update

 How to install Pi-Hole on Docker and Synology with MacVlan

We can create s special 'MacVlan' network, this will allow the pi-hole container to get a dedicated IP on our network. This will solve:

  • no port clashes with Synology as all ports will run only on dedicated IP
  • Client IP's visible as we are part of the real network
  • pi-hole has its own IP we can reach -> almost like a VM but still a container
few items you need for this.
  • You need to install Docker from the Package Center.
  • You need to enable "Open vSwitch" under Control panel > Network > Network interface > Select LAN then click Manage.

Networking

Login SSH as root and identify the ovs switch name use the following command.

ip route |grep default

the output will look like this:

default via 192.168.1.1 dev ovs_eth0 src 192.168.1.3

so in my case ovs_eth0 is what I will use.

Next, create the macvlan network name pi-hole-LAN, you need the know the following items:

  • Gateway of your network 
  • The subnet of your network
  • Free IP in your network 192.168.1.10/32 "/32 is for one IP,  

in my case the command looks like this:

docker network create --driver=macvlan --gateway=192.168.1.1 --subnet=192.168.1.0/24 --ip-range=192.168.1.10/32 -o parent=ovs_eth0 pi-hole-LAN

Run this command to pull the lastest Pi-hole image 

docker pull pihole/pihole

Run this command to create a directory for the config files

mkdir -p {/volume1/docker/pihole/pihole,/volume1/docker/pihole/dnsmasq.d}

Replacing the IP and change the password for pi-hole, and run  command to deploy the container, 

docker run --detach \
           --name pihole-pihole1 \
           --restart always \
           --volume /etc/localtime:/etc/localtime:ro \
           --volume /volume1/docker/pihole/pihole:/etc/pihole \
           --volume /volume1/docker/pihole/dnsmasq.d:/etc/dnsmasq.d \
           --dns=1.0.0.1 \
           --dns=1.1.1.1 \
           --env "DNS1=1.1.1.1" \
           --env "DNS2=1.0.0.1" \
           --env "ServerIP=192.168.1.10" \
           --env "DNSMASQ_LISTENING=local" \
           --env "WEBPASSWORD=password" \
           --env "TZ=America/New_York" \
           --network pi-hole-LAN \
           --ip "192.168.1.10" \
           --mac-address "02:42:c0:a8:01:d4" \
           --hostname "Pi-hole" \
           pihole/pihole:latest




Auto Update

Control Panel > Task Scheduler > Create > Scheduled Task > User-dafined Script

Task name:  Update Pi-hole



Set the schedule you want



Copy your installation script in to the User-defined script. 







All done.



docker pull pihole/pihole && docker stop pihole-pihole1 && docker rm pihole-pihole1
docker run --detach \
           --name pihole-pihole1 \
           --restart always \
           --volume /etc/localtime:/etc/localtime:ro \
           --volume /volume1/docker/pihole/pihole:/etc/pihole \
           --volume /volume1/docker/pihole/dnsmasq.d:/etc/dnsmasq.d \
           --dns=1.0.0.1 \
           --dns=1.1.1.1 \
           --env "DNS1=1.1.1.1" \
           --env "DNS2=1.0.0.1" \
           --env "ServerIP=192.168.1.10" \
           --env "DNSMASQ_LISTENING=local" \
           --env "WEBPASSWORD=password" \
           --env "TZ=America/New_York" \
           --network pi-hole-LAN \
           --ip "192.168.1.10" \
           --mac-address "02:42:c0:a8:01:d4" \
           --hostname "Pi-hole" \
           pihole/pihole:latest

Comments

  1. Thank you Rajani,
    You can add schedule to update for the pi-hole image automatically.

    ReplyDelete

Post a Comment

Popular posts from this blog

Extracting and using a modified VMWare Player BIOS or UEFI firmware

Activate Synology Active Backup for Business for DSM 6

Windows 11 internet/account bypass