apt-get update
apt-get install keepalived
apt-get install libipset3
apt-get install ntp
apt-get install ssh
Setup /etc/hosts on both
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
192.168.10.10 DietPiHole
192.168.10.11 DietPiHole-Cl1
192.168.10.12 DietPiHole-Cl2
# Config on Master:
# /etc/keepalived/keepalived.conf
global_defs {
notification_email {
mail@domain.com # Benachrichtigungs Zieladresse(n)
}
notification_email_from mail@domain.com # Benachrichtigungs Quelladresse
smtp_server localhost # SMTP Serveradresse
smtp_connect_timeout 30 # Timeout zum SMTP Server
router_id DietpiHole-Cl1 # Eindeutige ID wie z.B. HOSTNAME
script_user root # Benutzer der Notify Scripte
enable_script_security # Script Sicherheit einschalten
}
vrrp_instance PIHOLE {
state Master
interface eth0 # Genutztes Interface
virtual_router_id 51 # ID der Route
priority 150 # Master Prio 150, Backup Prio 50
advert_int 5 # Intervall der VRRP Pakete
smtp_alert # E-Mail Benachrichtigung aktiviren
unicast_src_ip 192.168.10.11 # Unicast Quelladresse
unicast_peer {
192.168.10.12 # Unicast Zieladresse(n)
}
authentication {
auth_type PASS # Authentifizierungs Typ
auth_pass 123Auslese123. # Authentifizierungs Passwort
}
virtual_ipaddress {
192.168.10.10/24 # Virtuelle Failover IP-Adresse
}
#notify_master "" # Notify Script für den Master Status (einkommentieren, wenn genutzt wird)
#notify_backup "" # Notify Script für den Backup Status (einkommentieren, wenn genutzt wird)
#notify_fault "" # Notify Script für den Fehler Status (einkommentieren, wenn genutzt wird)
}
# Config on Slave:
# /etc/keepalived/keepalived.conf
global_defs {
notification_email {
mail@domain.com # Benachrichtigungs Zieladresse(n)
}
notification_email_from mail@domain.com # Benachrichtigungs Quelladresse
smtp_server localhost # SMTP Serveradresse
smtp_connect_timeout 30 # Timeout zum SMTP Server
router_id DietpiHole-Cl2 # Eindeutige ID wie z.B. HOSTNAME
script_user root # Benutzer der Notify Scripte
enable_script_security # Script Sicherheit einschalten
}
vrrp_instance PIHOLE {
state BACKUP
interface eth0 # Genutztes Interface
virtual_router_id 51 # ID der Route
priority 50 # Master Prio 150, Backup Prio 50
advert_int 5 # Intervall der VRRP Pakete
smtp_alert # E-Mail Benachrichtigung aktiviren
unicast_src_ip 192.168.10.11 # Unicast Quelladresse
unicast_peer {
192.168.10.12 # Unicast Zieladresse(n)
}
authentication {
auth_type PASS # Authentifizierungs Typ
auth_pass 123Auslese123. # Authentifizierungs Passwort
}
virtual_ipaddress {
192.168.10.10/24 # Virtuelle Failover IP-Adresse
}
#notify_master "" # Notify Script für den Master Status (einkommentieren, wenn genutzt wird)
#notify_backup "" # Notify Script für den Backup Status (einkommentieren, wenn genutzt wird)
#notify_fault "" # Notify Script für den Fehler Status (einkommentieren, wenn genutzt wird)
}
systemctl enable keepalived.service
systemctl stop keepalived
on master:
ssh-keygen -t rsa
copy key from master to slave:
ssh-copy-id DietPiHole-Cl2
login to slave and check:
ssh dietpihole-cl2
mkdir /scripts
chmod 750 /scripts
nano /scripts/sync-pihole.sh
#!/bin/bash
echo "Start at $(date) " >> /var/log/pihole.sync
test -e /etc/pihole/whitelist.txt && scp /etc/pihole/whitelist.txt DietPiHole-Cl2:/etc/pihole/whitelist.txt
test -e /etc/pihole/blacklist.txt && scp /etc/pihole/blacklist.txt DietPiHole-Cl2:/etc/pihole/blacklist.txt
ssh DietPiHole-Cl2 pihole -g >> /var/log/pihole.sync
echo "Stop at $(date) " >> /var/log/pihole.sync
Either: call this script after editing white/blacklist on DietPiHole-Cl1
Or: create cron entry on DietPiHole-Cl1
:
Test setup (on DietPiHole-Cl1
):
systemctl stop keepalived
Clustered ip should switch to DietPiHole-Cl2
What is missing?
nmcli
nmcli device show