我有一个 BIND 9.9.5-9+deb8u8-Raspbian DNS 服务器在我的网络中的 RPi3 上运行。它 - 对于不是我的主区域的所有内容 - 配置为“仅转发”,转发器为“{ 8.8.8.8; 8.8.4.4; 208.67.222.222; 208.67.220.220; };”。
a) 正常情况
通常,dns 解析工作得很好。即使结果不在缓存中,它们也会从转发服务器中获取并通常在 100 毫秒内传送回我的客户端。下面是一个例子:
client:~ $ time nslookup faz.net
Server: [my_server]
Address: [my_server]#53
Non-authoritative answer:
Name: faz.net
Address: 40.118.6.229
real 0m0.095s […]
Run Code Online (Sandbox Code Playgroud)
这是流量在 tcpdump 中的样子,就我所见,一切都很完美,而且 DNSSEC 验证似乎也能正常工作:
06:48:21.880240 IP [my_client].59563 > [my_server].domain: 614+ A? faz.net. (25)
06:48:21.881246 IP [my_server].28766 > google-public-dns-a.google.com.domain: 30021+% [1au] A? faz.net. (36)
06:48:21.916031 IP google-public-dns-a.google.com.domain > [my_server].28766: 30021 1/0/1 A 40.118.6.229 (52)
06:48:21.917093 IP [my_server].44792 > google-public-dns-a.google.com.domain: 10551+% …
Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个脚本,用于inotifywatch
监视日志文件中的更改。如果将特定消息写入日志文件,则应该触发某个功能。该脚本目前以这种基本形式存在:
while inotifywait -e modify /var/log/auth.log
do
alert=$(tail -n1 /var/log/auth.log | grep -E -o ".{0,7}password")
if [[ $alert == "Failed password" ]]
then
echo "FAILURE" >> test.log
elif [[ $alert == "cepted password" ]]
then
echo "LOGIN" >> test.log
fi
done
Run Code Online (Sandbox Code Playgroud)
一切正常——直到观察到的日志文件inotifywatch
被旋转。然后它停止工作。我认为这是因为在轮换期间,被监视的文件被重命名,之后不再写入,并且在其位置创建了一个具有旧名称的新文件,该文件inotify
从未被告知首先要监视。
我试图通过从切换inotifywatch
到使用来规避这一点,tail -f
但同样的问题似乎也适用于那里。
现在我意识到这可能可以通过创建一个巨大的if
结构来解决,其中inotifywatch
不仅modify
监视 ,还监视文件创建并重新启动监视进行修改。但是我喜欢保持简单,所以有人知道是否有更简单的方法吗?(拜托,不,我不想使用像 fail2ban 等预制的解决方案——对我来说有趣的部分是自己用简单的工具创建这样的东西。)