linux – 为AWStats手动创建dnscache.txt

linux – 为AWStats手动创建dnscache.txt,第1张

概述根据AWStats的文档: AWStats can do reverse DNS lookups through a static DNS cache file that was previously created manually. 通过文档搜索,以及相当多的谷歌搜索,给我留下了一个问题.如何手动创建DNS缓存文件?是否有Linux命令要执行此 *** 作,我还没有找到?这是在Centos 5.5机器 根据AWStats的文档:

AWStats can do reverse DNS lookups through a static DNS cache file
that was prevIoUsly created manually.

通过文档搜索,以及相当多的谷歌搜索,给我留下了一个问题.如何手动创建DNS缓存文件?是否有Linux命令要执行此 *** 作,我还没有找到?这是在Centos 5.5机器上.

解决方法 如下所述,您可以使用任何文本编辑器来创建格式为ipaddress resolved_hostname的文本文件,如下所示:
192.168.1.11    websrv1192.168.1.12    websrv2192.168.1.13    websrv3

不要忘记设置DNSLookup = 2.

I had expected to be able to create the file from existing
information,such as the Apache logs.

当然,你可以通过从Apache的access_log获取IP地址并使用一些工具来实现,例如:dig,host,resolveip,…来解析主机名,如下所示:

$awk '{ print  }' access_log | sort | uniq | \while read ip; do \    if [ `dig +short -x $ip | sed 's/\(.*\)\.//' | wc -l` -eq 1 ]; then \        echo -e $ip\t$(dig +short -x $ip | sed 's/\(.*\)\.//') >> dnscache.txt; \    fi; \done

要继续更新此文件,可以将上述命令作为cron作业运行,并仅过滤特定时间范围内的日志(等于cron interval).

总结

以上是内存溢出为你收集整理的linux – 为AWStats手动创建dnscache.txt全部内容,希望文章能够帮你解决linux – 为AWStats手动创建dnscache.txt所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/1036048.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存