apt-get updateapt-get install keepalivedapt-get install libipset3apt-get install ntpapt-get install sshSetup /etc/hosts on both
127.0.0.1 localhost::1 localhost ip6-localhost ip6-loopbackff02::1 ip6-allnodesff02::2 ip6-allrouters192.168.10.10 DietPiHole192.168.10.11 DietPiHole-Cl1192.168.10.12 DietPiHole-Cl2# Config on Master:# /etc/keepalived/keepalived.confglobal_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.confglobal_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.servicesystemctl stop keepalivedon master:
ssh-keygen -t rsacopy key from master to slave:
ssh-copy-id DietPiHole-Cl2login to slave and check:
ssh dietpihole-cl2mkdir /scriptschmod 750 /scriptsnano /scripts/sync-pihole.sh
#!/bin/bashecho "Start at $(date) " >> /var/log/pihole.synctest -e /etc/pihole/whitelist.txt && scp /etc/pihole/whitelist.txt DietPiHole-Cl2:/etc/pihole/whitelist.txttest -e /etc/pihole/blacklist.txt && scp /etc/pihole/blacklist.txt DietPiHole-Cl2:/etc/pihole/blacklist.txtssh DietPiHole-Cl2 pihole -g >> /var/log/pihole.syncecho "Stop at $(date) " >> /var/log/pihole.syncEither: call this script after editing white/blacklist on DietPiHole-Cl1
Or: create cron entry on DietPiHole-Cl1:
Test setup (on DietPiHole-Cl1):
systemctl stop keepalivedClustered ip should switch to DietPiHole-Cl2
What is missing?
nmclinmcli device show