5EL*_*5Hk 6 centos icmp timestamp firewalld
操作系统:CentOS 7.0
根据安全扫描的结果,有人建议我们使用防火墙 ( CVE-1999-0524 )阻止 ICMP 时间戳和时间戳回复消息。我已经使用 firewalld 为 SSH 设置了一些基本的 IP 过滤并允许使用 HTTPS,但我对这个感到困惑。
我唯一能想到的是firewall-cmd --add-icmp-block
,但我找不到icmptype
似乎与时间戳或时间戳回复相关的 。
可用的类型 ( firewall-cmd --get-icmptypes
) 如下:
destination-unreachable echo-reply echo-request parameter-problem redirect router-advertisement router-solicitation source-quench time-exceeded
.
如何阻止 ICMP 时间戳请求firewalld
?
daw*_*wud 17
firewalld
附带一组默认的预定义 ICMP 类型,您可以开箱即用:
# firewall-cmd --get-icmptypes
destination-unreachable echo-reply echo-request parameter-problem redirect router-advertisement router-solicitation source-quench time-exceeded timestamp-reply timestamp-request
Run Code Online (Sandbox Code Playgroud)
但是,解析器 ( /usr/lib/python2.7/site-packages/firewall/core/io/icmptype.py
) 不限于这些类型,并且允许扩展:
首先,根据man iptables-extensions(8)
,部分icmp
:
icmp (IPv4-specific) 如果指定了`--protocol icmp',可以使用这个扩展。它提供以下选项:
Run Code Online (Sandbox Code Playgroud)[!] --icmp-type {type[/code]|typename} This allows specification of the ICMP type, which can be a numeric ICMP type, type/code pair, or one of the ICMP type names shown by the command iptables -p icmp -h
icmp6 (IPv6-specific) 如果
--protocol ipv6-icmp' or
指定了--protocol icmpv6',则可以使用此扩展。它提供以下选项:Run Code Online (Sandbox Code Playgroud)[!] --icmpv6-type type[/code]|typename This allows specification of the ICMPv6 type, which can be a numeric ICMPv6 type, type and code, or one of the ICMPv6 type names shown by the command ip6tables -p ipv6-icmp -h
您引用的两种类型是特定于 IPv4 的,因此您应该使用以下内容来找出由 识别的适当名称iptables
:
# iptables -p icmp -h | grep timestamp
timestamp-request
timestamp-reply
Run Code Online (Sandbox Code Playgroud)
现在,如果您检查firewalld
包的内容,您将找到预定义 ICMP 类型的存储位置:
# rpm -ql firewalld | grep icmptype
/etc/firewalld/icmptypes
/usr/lib/firewalld/icmptypes/destination-unreachable.xml
/usr/lib/firewalld/icmptypes/echo-reply.xml
/usr/lib/firewalld/icmptypes/echo-request.xml
/usr/lib/firewalld/icmptypes/parameter-problem.xml
/usr/lib/firewalld/icmptypes/redirect.xml
/usr/lib/firewalld/icmptypes/router-advertisement.xml
/usr/lib/firewalld/icmptypes/router-solicitation.xml
/usr/lib/firewalld/icmptypes/source-quench.xml
/usr/lib/firewalld/icmptypes/time-exceeded.xml
/usr/lib/firewalld/xmlschema/icmptype.xsd
/usr/share/man/man5/firewalld.icmptype.5.gz
Run Code Online (Sandbox Code Playgroud)
如果您检查上面引用的解析器,您会看到它在与 对话时使用 XML 文件名作为 ICMP 类型iptables
,因此您需要使用上面找到的 ICMP 类型为要使用的 ICMP 类型编写两个新文件。用户创建的 ICMP 类型应存储在/etc/firewalld/icmptypes
.
# cat timestamp-request.xml
<?xml version="1.0" encoding="utf-8"?>
<icmptype>
<short>Timestamp Request</short>
<description>This message is used for time synchronization.</description>
<destination ipv4="yes"/>
<destination ipv6="no"/>
</icmptype>
# cat timestamp-reply.xml
<?xml version="1.0" encoding="utf-8"?>
<icmptype>
<short>Timestamp Reply</short>
<description>This message is used to reply to a timestamp message.</description>
<destination ipv4="yes"/>
<destination ipv6="no"/>
</icmptype>
Run Code Online (Sandbox Code Playgroud)
你最终会得到:
# ll -Z /etc/firewalld/icmptypes
-rw-r--r--. root root system_u:object_r:firewalld_etc_rw_t:s0 timestamp-reply.xml
-rw-r--r--. root root system_u:object_r:firewalld_etc_rw_t:s0 timestamp-request.xml
Run Code Online (Sandbox Code Playgroud)
使用提供的 XSD 验证它们:
# xmllint --schema /usr/lib/firewalld/xmlschema/icmptype.xsd timestamp-request.xml
timestamp-request.xml validates
# xmllint --noout --schema /usr/lib/firewalld/xmlschema/icmptype.xsd timestamp-reply.xml
timestamp-reply.xml validates
Run Code Online (Sandbox Code Playgroud)
重新加载防火墙:
# firewall-cmd --reload
Run Code Online (Sandbox Code Playgroud)
最后添加它们:
# firewall-cmd --add-icmp-block=timestamp-request
# firewall-cmd --add-icmp-block=timestamp-reply
# firewall-cmd --list-icmp-blocks
timestamp-reply timestamp-request
Run Code Online (Sandbox Code Playgroud)
您可以iptables
直接查看规则来检查它们是否已添加:
iptables -nvL | grep icmp
0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0
0 0 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
0 0 REJECT all -- * virbr0 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
0 0 REJECT all -- virbr0 * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0
0 0 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
0 0 REJECT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmptype 13 reject-with icmp-host-prohibited
0 0 REJECT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmptype 14 reject-with icmp-host-prohibited
0 0 REJECT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmptype 13 reject-with icmp-host-prohibited
0 0 REJECT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmptype 14 reject-with icmp-host-prohibited
Run Code Online (Sandbox Code Playgroud)
类型 13 和 14 是新添加的ICMP 类型。
作为参考,您可以阅读firewalld.icmptypes(5)
联机帮助页。
这些 ICMP 类型已包含在上游。
归档时间: |
|
查看次数: |
13959 次 |
最近记录: |