我有大约50k的IP地址在hosts.deny文件中被拒绝,这个文件是由每行最多7个地址的脚本产生的,并且得到这个错误:
warning: /etc/hosts.deny, line 4429: missing newline or line too long
4429行是在这里中间的一个:
ALL: 96.47.225.95, 96.47.225.96, 96.47.225.97, 96.47.225.98, 96.47.225.99, 96.56.113.123, 96.8.112.149 ALL: 98.126.161.178, 98.15.206.118, 98.159.4.16, 98.197.212.67, 98.83.135.94, 98.94.6.213, 98.94.6.78 ALL: 99.167.89.146, 99.177.96.73, 99.235.84.25, 99.244.9.103, 99.49.94.70
怎么了?
更新:
只有在连接完成时,才会显示警告,同时写入hosts.deny文件。 (I / O,locking,打开,打开读取问题)。
在我看来,有这么大的`/etc/hosts.deny'文件是没有意义的,原因如下:
denyhosts , fail2ban , psad等等,这将为邪恶的行动者提供一些保护,而不会陷入前面提到的陷阱。 现在,如果您确实需要维护这样的文件,可以尝试使用文件,如PATTERNS部分下的hosts_access(5)联机帮助页中所述:
格局
The access control language implements the following patterns: · A string that begins with a `/´ character is treated as a file name. A host name or address is matched if it matches any host name or address pattern listed in the named file. The file format is zero or more lines with zero or more host name or address patterns separated by whitespace. A file name pattern can be used anywhere a host name or address pattern can be used.
我试了一下,并生成了一个列表:
# echo 123.{1..255}.{1..255}.{1..254} > /etc/list
将其添加到/etc/hosts.deny文件中:
# echo 'ALL: /etc/list' >> /etc/hosts.deny
尝试了一些连接,并检查我的日志。 我没有能够重现你提到的警告。