Skip to content

Instantly share code, notes, and snippets.

@Tugzrida
Created January 13, 2019 00:11
Show Gist options
  • Save Tugzrida/3be26eebf59dafd71a50183c4b2a6ec6 to your computer and use it in GitHub Desktop.
Save Tugzrida/3be26eebf59dafd71a50183c4b2a6ec6 to your computer and use it in GitHub Desktop.
Crude DNS cacher to reduce number of upstream lookups
#!/bin/bash
# Requires install of dnsutils package. Can be added to a crontab with root permissions
# for however often you want to refresh the cached IP.
host="pfclient-upload.planefinder.net"
ipaddr=$(dig +short "$host" | awk '{ print ; exit }')
grep -v "$host" /etc/hosts | tee /etc/hosts
echo "$ipaddr $host" | tee -a /etc/hosts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment