Created
May 18, 2024 16:09
-
-
Save ahmetozer/7209e8213303238d2123660e0e2bc392 to your computer and use it in GitHub Desktop.
dnsmasq dhcp fallback
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
ON_BACKUP=0 | |
while true; do | |
if netcat -zuvn 10.0.1.2 67 > /dev/null 2>&1 ; then | |
if [[ $ON_BACKUP != false ]]; then | |
echo "Switching to primary" | |
ON_BACKUP=false | |
service dnsmasq stop > /dev/null 2>&1 | |
fi | |
else | |
if [[ $ON_BACKUP != true ]]; then | |
echo "Switching to backup" | |
ON_BACKUP=true | |
service dnsmasq start > /dev/null 2>&1 | |
fi | |
fi | |
sleep 10 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment