2024-02-26 14:26:05 -07:00
|
|
|
# pihole-opnsense-sync
|
2024-02-26 14:43:04 -07:00
|
|
|
|
2024-02-26 14:26:05 -07:00
|
|
|
_Sync custom DNS entries in Pi-hole to OPNsense Unbound._
|
|
|
|
|
2024-02-26 14:46:19 -07:00
|
|
|
This little service watches Pi-hole's `/etc/pihole/custom.list` file and when a change is made, it syncs it with your
|
|
|
|
OPNsense router's Unbound host overrides. This is useful because if your Pi-hole goes offline then you will still be
|
|
|
|
able to resolve your custom domains.
|
|
|
|
|
2024-02-26 14:26:05 -07:00
|
|
|
## Install
|
|
|
|
|
2024-02-26 14:43:04 -07:00
|
|
|
1. Install pip requirements:
|
|
|
|
```shell
|
|
|
|
pip install -r requirements.txt
|
|
|
|
```
|
|
|
|
2. Create your secrets file at `/etc/secrets/pihole-opnsense-sync` with your API details:
|
|
|
|
```bash
|
|
|
|
OPNSENSE_API_KEY='...'
|
|
|
|
OPNSENSE_API_SECRET='...'
|
|
|
|
```
|
2024-02-28 14:29:14 -07:00
|
|
|
3. Give your user the `Services: Unbound DNS: Edit Host and Domain Override` permision.
|
|
|
|
4. Set the permissions on this file:
|
2024-02-26 14:43:04 -07:00
|
|
|
```shell
|
|
|
|
sudo chown root:root /etc/secrets/pihole-opnsense-sync
|
|
|
|
sudo chmod 600 /etc/secrets/pihole-opnsense-sync
|
|
|
|
```
|
2024-02-28 14:29:14 -07:00
|
|
|
5. Copy the systemd service file:
|
2024-02-26 14:43:04 -07:00
|
|
|
```shell
|
|
|
|
sudo cp pihole-opnsense-sync.service /etc/systemd/system/pihole-opnsense-sync.service
|
|
|
|
```
|
2024-02-28 14:26:50 -07:00
|
|
|
The service is configured to run as the `pihole:pihole` user.
|
2024-02-28 14:29:14 -07:00
|
|
|
6. Edit the service file. You might need to modify `--opnsense` and add `--insecure`.
|
|
|
|
7Enable and start the service:
|
2024-02-26 14:43:04 -07:00
|
|
|
```shell
|
|
|
|
sudo systemctl enable --now pihole-opnsense-sync
|
2024-02-26 14:46:19 -07:00
|
|
|
sleep 2
|
2024-02-26 14:43:04 -07:00
|
|
|
sudo systemctl status pihole-opnsense-sync
|
|
|
|
```
|