DNSHISTORY(1)
π DNSHISTORY(1) π
okay bestie, sit DOWN. this is dnshistory from the User Commands section and it is genuinely iconic. it takes your messy little log files, does DNS lookups on the IP addresses in them, and keeps a cute little history database so you never have to ask twice. π¦
β¨ NAME β¨
dnshistory β processes various log file formats doing dns IP Address lookups. Store these pairs in a database for later retrieval.
like. it reads the logs. it finds the IPs. it asks the DNS who they are. it writes it all down. main character energy fr fr. π
πΈ SYNOPSIS πΈ
dnshistory [OPTION]... [--file=FILE]
π COPYRIGHT π
dnshistory is Copyright Β© 2004, 2005, 2006, 2007 Stephen McInerney
π DESCRIPTION π
so rn dnshistory processes Apache CLF and Combined logs, Squid access logs, FTP xferlog files and iptables based logs. and the log format? auto-detected. it just knows. β¨
dnshistory has five modes of operation:
- Do Lookups. The default mode. Given a web log file,
dnshistorywill perform DNS reverse lookups on each unique IP Address and store the results in a history database. - Do Translations. Given a raw web log file,
dnshistorywill make use of a previously created history database and send to STDOUT the same web log but with addresses replaced by the Fully Qualified Domain Name as previously looked up. - Do Recombining. Given two web log files, one raw and one previously translated (eg. by using
dnstran): Create a history database from the values in these separate log files. - Do Dump. Dump a given history database to STDOUT.
- Do Import. Import a previously dumped history database from a given file.
- Show History. Given one or more IP Addresses on the command line, show the history of those addresses.
The lookups make use of threads for maximum speed, and use the standard resolution libraries on a system. Thus hosts files, NIS, LDAP and other name resolution methods should work transparently. no cap, it just slots into whatever your system already does. π«Ά
It is strongly recommended that for massive lookups a DNS server is "nearby". Preferably not a forwarding server. like literally, keep your DNS bestie close or this gets rough. π
dnshistory can read .gz files. STDIN is assumed to not be gz encoded. (so don't try to pipe zipped stuff in, it's giving chaos π«)
β OPTIONS β
-L,--dolookupsβ The default mode. Given a log file, either via STDIN or via'-f', do the lookups and store the results. this is the one that runs if you say nothing at all π-T,--dotranslateβ Given a log file, either via STDIN or via'-f', lookup each IP Address from the history database; replace the IP Address with the FQDN and send the newly updated log line to STDOUT. glow-up for your log file honestly β¨-R,--dorecombine=FILEβ Given a previously translated file (eg. viadnstran) via this option for the names, do the lookups for a file given via STDIN or'-f'and store the results. This file can be gz encoded.
The date/time of each stored entry is taken as being the actual time for the lookup stored in the recombine log file. This is probably incorrect, but "Good Enough". π
-D,--dodumpβ Dump the history database to STDOUT.-I,--doimport=FILEβ Given a previously dumped database, import that into a new database. Will fail and exit if the chosen database already exists. it's not gonna overwrite your stuff, periodt.-S,--showhistoryβ Given one or more IP Addresses show their history. Address are the last item(s) on the command line. Addresses with no as yet discovered FQDN will display'NONAME'. The Date/Time displayed is formatted asYYYY-MM-DD:hh:mm:ss, vs the'seconds since epoch'for"--dodump"--logtype=LOGTYPEβ By defaultdnshistorywill attempt to autodetect what type of logfile is being processed. By using this option, the autodetection is overridden. The choices are:auto,clforwww,squid,ftporiptables.-c,--cache=SIZEβ Set the size of the memory cache to use. Value is in Mb. Default is 20Mb.-d,--database=FILEβ Change the default database file to use to store stateful data.-f,--file=FILEβ Web Log File to process. This file can be gz encoded. Will use STDIN if not set-h,--helpβ Help screen. Very brief. (it said what it said π)-l,--maxlookups=NUMBERβ The maximum number of lookups to attempt. The default is 1. This has not shown to be at all useful in testing... π-m,--maxthreads=NUMBERβ How many name lookup threads to spawn off. The default is 100. Setting this too high can do evil things to bandwidth and the CPU usage of any queried DNS server(s).
If doing lots of DNS queries, setting this too high can have a very negative impact on the ability to successfully resolve anything. so like, don't be greedy bestie, more threads β more slay π
-t,--timeout=VALUEβ The time in seconds before a stored DNS value is deemed "old". The default is 7 days.-v,--verboseβ Verboseness of a run. More v's will increase the level of verbosity, up to a maximum of 5. All of the higher levels are only of value for debugging purposes.-V,--versionβ Display the version information and exit-w,--waitβ Delay time between query retries within a single run
π RESULTS π
- At verbose level 1 (
-v) some success/failure counters will be displayed. As well as any problematic log lines to STDERR. - At verbose level 2 (
-vv) lines that may not match up (eg. Due todnstranmodifying referrers or URL's) will be sent to STDERR.
π EXAMPLES π
A typical run, using a database in /tmp/ (/tmp/c.db), and a log file in the current directory (test.log). First, do the lookups:
dnshistory -d /tmp/c.db -f test.log
Then the translation run for input into, for example, a web log analyser:
dnshistory -T -d /tmp/c.db -f test.log | webalizer ....
Do three attempts on failed queries, with a 2 second delay between retries:
dnshistory -l 3 -w 2 -d /tmp/c.db -f test.log
Lookup and Display the history of three IP Addresses: 127.0.0.1, 192.168.1.254, 10.10.10.10
dnshistory -S -d /tmp/c.db 127.0.0.1 192.168.1.254 10.10.10.10
Import a previously dumped database via dnsdb.dump
dnshistory -I dnsdb.dump -d /tmp/d.db
π§ FILES π§
/var/lib/dnshistory/dnshistory.dbβ The default history database file.
π BUGS π
- Ignores IP Addresses located in the URL and Referrer fields. (yeah. it does that. we don't talk about it π)
π AUTHOR π
Stephen McInerney <spm@stedee.id.au>
and that's the whole page bestie!! this one's a Linux manual, January 2007 edition, and it's genuinely one of the good ones β threads, auto-detection, gz support, the works. go do your lookups, stay hydrated, and remember: keep that DNS server nearby. πβ¨ππ¦πΈπ
π¦ where this page comes from
- debian bookworm: dnshistory 1.3-3
- ubuntu jammy: dnshistory 1.3-2.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms