Skip to content

Instantly share code, notes, and snippets.

@Razuuu
Forked from lyjacky11/update_root_hints.sh
Last active May 14, 2025 23:18
Show Gist options
  • Save Razuuu/581d8f32fd015d634ed69140ce001372 to your computer and use it in GitHub Desktop.
Save Razuuu/581d8f32fd015d634ed69140ce001372 to your computer and use it in GitHub Desktop.
Update root.hints file for bind9
#!/bin/bash
# Vars
HEREAMI="$(dirname "$(readlink -f "${0}")")"
URL="https://www.internic.net/domain/named.root"
FILE="/usr/share/dns/root.hints"
# Check if file is the same, otherwise override
if ! diff -q <(curl -s "${URL}") "${FILE}" > /dev/null 2>&1; then
# Download root.hints file
curl -s ${URL} -o ${FILE}
# Set last updated in file
echo "Last updated: $(date +%d.%m.%Y) at $(date +%H:%M:%S)" > ${HEREAMI}/last_updated_root_hints_file.txt
fi
# Restart bind9/named
/usr/bin/systemctl restart named
# Exit script
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment