Skip to content

Instantly share code, notes, and snippets.

@it-engineer-pro
Forked from lyjacky11/update_root_hints.sh
Last active May 30, 2024 20:58
Show Gist options
  • Save it-engineer-pro/6965e510ff6df1e0eb891e4be4cf1ccc to your computer and use it in GitHub Desktop.
Save it-engineer-pro/6965e510ff6df1e0eb891e4be4cf1ccc to your computer and use it in GitHub Desktop.
Update root.hints file for Pi-Hole Unbound Service
#!/bin/bash
# wget -nv -O named.root https://www.internic.net/domain/named.root
echo "[i] Backing up root.hints ..."
cd /var/lib/unbound
sudo cp root.hints $(date +%F).root.hints
if [ -s $(date +%F).root.hints ]
then
echo "[✓] Backup root.hints success!"
echo ""
echo "[i] Updating root.hints ..."
sudo wget -nv -O named.root https://www.internic.net/domain/named.root
if [ -s named.root ]
then
sudo mv -f named.root root.hints
echo "[✓] Update root.hints success!"
echo ""
echo "[i] Restarting unbound service ..."
sudo service unbound restart
sudo service unbound status
exit 0
else
echo "[✗] Update failed!"
exit 1
fi
else
echo "[✗] Backup failed!"
exit 1
fi
@it-engineer-pro
Copy link
Author

it-engineer-pro commented May 15, 2024

Short bash script for updating root.hints for Unbound DNS server in Pi-Hole.
It can be used, as example for updating root.hints in Bind stack or any other solutions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment