Installing Pi-hole on OpenWrt Router (NanoPi R5C) for Ad Filtering and DNS Caching

NO.1
Pi Hole

Note:

This Pi Hole deployment on OpenWrt was successful, but it failed to work.

DNS filtering only works within OpenWrt, and there is no data reflected on other clients.

Therefore, after this deployment, the R5C will prioritize resolving the wireless card issue, and other plugins and Docker applications will be postponed.

I previously installed it successfully on an x86 machine and tried it for a week.

The ad-blocking effect was not significant, but the service was relatively stable, and network data was visualized.

I am now preparing to implement ad-blocking directly on the OpenWrt router from the network layer.

Reference article

HomeLab Mini Host (x86): Setting up Pi-hole with Docker for Ad Filtering

Installing Pi-hole on OpenWrt Router (NanoPi R5C) for Ad Filtering and DNS Caching

NO.2
Installing Pi-hole on OpenWrt

After installing CodeServer last time, I used online VScode for editing.

Reference article

OpenWrt Router (NanoPi R5C): Installing nano editor and CodeServer browser-based VScode editor

The directory mapping from the last article was changed to a relative directory.

It took several restarts to successfully map.

You can see that the left-side WorkSpace is my dockerCompose directory.

Installing Pi-hole on OpenWrt Router (NanoPi R5C) for Ad Filtering and DNS Caching

Editing the Pi Hole docker-compose.yml file

version: "3"

# More info at https://github.com/pi-hole/docker-pi-hole/ and https://docs.pi-hole.net/
services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    # For DHCP it is recommended to remove these ports and instead add: network_mode: "host"
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      # - "67:67/udp" # Only required if you are using Pi-hole as your DHCP server
      - "3003:80/tcp"
    environment:
      TZ: 'America/Chicago'
      # WEBPASSWORD: 'set a secure password here or it will be random'
    # Volumes store your data between container upgrades
    volumes:
      - './etc-pihole:/etc/pihole'
      - './etc-dnsmasq.d:/etc/dnsmasq.d'
    #   https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
    cap_add:
      - NET_ADMIN # Required if you are using Pi-hole as your DHCP server, else not needed
    restart: unless-stopped

Installing Pi-hole on OpenWrt Router (NanoPi R5C) for Ad Filtering and DNS Caching

Pulling the image and running

docker-compose up

Prompt: Port 53 is occupied (the previous x86 Ubuntu was also occupied by default).

Installing Pi-hole on OpenWrt Router (NanoPi R5C) for Ad Filtering and DNS Caching

Resolving the port 53 occupation issue

Click on Network – DHCP/DNS – Advanced Settings – Change DNS port to 5353.

Click save and apply.

Installing Pi-hole on OpenWrt Router (NanoPi R5C) for Ad Filtering and DNS Caching

Then check the previously not started pihole and click start.

You can see it has changed to normal start.

Installing Pi-hole on OpenWrt Router (NanoPi R5C) for Ad Filtering and DNS Caching

Access IP: Port

Installing Pi-hole on OpenWrt Router (NanoPi R5C) for Ad Filtering and DNS Caching

The rest refers to the previous article, set the password, set DNS, set the ad list, etc.

HomeLab Mini Host (x86): Setting up Pi-hole with Docker for Ad Filtering

Installing Pi-hole on OpenWrt Router (NanoPi R5C) for Ad Filtering and DNS Caching

After entering the homepage, I won’t record the configuration.

Installing Pi-hole on OpenWrt Router (NanoPi R5C) for Ad Filtering and DNS Caching

NO.3
Tips

Test results

There is data, but the panel does not update in real time like x86; instead, you have to switch Chrome tabs or wait a moment.

Only then will the panel data refresh, and there is a delay in data updates.

Ultimately, testing switched to the OpenWrt panel showed data fluctuations, and all data was marked as OpenWrt client data.

It is unclear whether the firewall is not configured correctly, or if there are issues with LAN or network card DNS settings.

In summary, the Pi Hole set up this time only works internally within OpenWrt and does not reach the clients at all.

Therefore, this article abandons the OpenWrt PiHole ad filtering, and I will continue to use the previous x86 Pi Hole.

Installing Pi-hole on OpenWrt Router (NanoPi R5C) for Ad Filtering and DNS Caching

Note

Remember to change the previous DNS port from 5353 back to 53.

Also, I looked at AdGuardHome for ad filtering, and it is said that all OpenWrt have this service plugin, but this firmware does not seem to have it, and I can’t download it, so I gave up on that as well.

Focus on the content of the router itself first, and once the USB network card and M2 network card arrive, prioritize setting up the wireless solution.

Other independent services will be handled by x86.

R5C Collection

“OpenWrt Router NanoPi NAS R5C”

The R5C OpenWrt series, aside from different firmware, from the second article on expanding the Docker partition onwards, the content of the series articles is also applicable to the R2S, R4S, R5S, R6S series. If not in use, it can also be used for reference.

END.

Send the keywordJoin Group, to join the discussion group.

If you think this article is good, feel free tolike and bookmark, see you next time.

Recommended reading

OpenWrt Router (NanoPi R5C): Installing nano editor and CodeServer browser-based VScode editor

☕ Friends, if you have seen this, are you sure you won’t follow up? 👇

Leave a Comment