Note

Quick note!

This post aims to automate the problem outlined in my original post (🥧 Fixing some niggles between Eero + PiHole) which used a far inferior solution.

Read below the the new and improved automated solution!

Overview of the problem

You can read more about the problem in my earlier post, but essentially there is no direct integration between Eero and PiHole, so the client list in Eero shows up as:

And I want it to look like this:

The Solution

This new solution uses 2 main parts:

  • A CLI application to retrieve device information from the Eero
  • A cron job to run the application and update PiHole

I’m sure you are all eager to know more about this and start implementing it. So lets get going!

There are a few steps that needs to be followed which I have listed below.

1. Create a IP reservation for each client in Eero

This setting ensures that each device has a unique IP address which is always set for that device. E.g my server will always live on 192.168.1.200.

I have set up my own network so that DHCp is provided for the 2-99 range. And then the 100+ range is all allocated.

  • 100-109 - Laptops
  • 110-119 - Phones
  • 150-199 - IOT devices
  • etc

2. Name each device

I set each device up with a friendly network name. This is what is shown up in the Eero itself, but also what PiHole will map the IP address to.

3. Create the PiHole Config files

2 file are needed for this to work, and have been listed below.

File: /etc/dnsmasq.d/20-eero-home-config.conf

addn-hosts=/etc/pihole/custom-home.list

File: /etc/pihole/custom-home.list

# Blank for now

4. Download the GoEero CLI client

I actually had to learn Go to build this application to interact with the Eero, which is the key part of this solution.

Navigate to https://github.com/ab623/goeero to build the GoCode, or download a prebuilt release from https://github.com/ab623/goeero/releases/. You will likely need the linux amd64, if you are using docker or a linux machine.

Store this application in any accessible location. I stored it in /goeero

5. Create the Cron Job

Create a new file called updateCustomHosts in /etc/cron.hourly, ensuring the file is executable. Storing any shell script in that folder will ensure its automatically called every hour.

The contents of the shell script is below

#!/bin/sh

# This script collects the required data in
# 1. Get the list of devices in JSON format
# 2. Clean and format the data in the expected host file format
# 3. Sort the list
# 4. Store the data in the correct file
# 5. Reload PiHole so it uses the correct data

/goeero/eeroclient --session-file /goeero/eero_session.txt devices | \ 
jq -r '.[] | select(.ip | length > 0) | [.ip, .display_name | gsub("( - |-| |_)";"-")] | @tsv' | \
sort -k2 > \
/etc/pihole/custom-home.list \
&& /usr/local/bin/pihole restartdns

Notes:

  • I have hardcoded paths into this script, ensure you update the paths to eeroclient, pihole and custom-home.list, if any of them are stored in different locations than what was described above.
  • The eeroclient application needs to authenticated before its first use. You can do this by following the instructions on Github, or by running ./eeroclient auth
  • The hourly cron does not tend to run on the change of the hour, in case you were expecting updates and they didn’t happen.

Conclusion

Using this method, I have been able to fully automate this solution. I simply have to provide my devices with friendly names in the app, along with an IP allocation, and the automation will take care of the rest.

I am extremely happy with this refined and automated approach. If you have any question of course feel free to email me directly.