As it said underneath, you can use any text editor you want to create a text file with format ipaddress resolved_hostname
, something like this:
192.168.1.11 websrv1
192.168.1.12 websrv2
192.168.1.13 websrv3
Don't forget to set DNSLookup=2
.
I had expected to be able to create the file from existing
information, such as the Apache logs.
Sure, you can do it by getting IP address from the Apache's access_log
and use some tools such as: dig
, host
, resolveip
, ... to resolve to host name, something like this:
$ awk '{ print $1 }' access_log | sort | uniq | \
while read ip; do \
if [ `dig +short -x $ip | sed 's/\(.*\)\./\1/' | wc -l` -eq 1 ]; then \
echo -e $ip\\t$(dig +short -x $ip | sed 's/\(.*\)\./\1/') >> dnscache.txt; \
fi; \
done
To continue updating this file, you can run the above command as a cron job and filter only logs in a specific time range (equal to cron interval).