修复方案:过滤 ICMP 时间戳请求(Type 13)和响应(Type 14)
ICMP 时间戳请求(Type 13)和响应(Type 14) 可能被攻击者用于网络探测(如主机发现、时间同步分析),建议在防火墙或主机层面禁用。
1. 检测当前是否允许 ICMP 时间戳
(1)使用 nmap
检测
nmap -Pn --script icmp-timestamp -p 80 your-server.com
- 如果返回
TIMESTAMP REPLY
,说明服务器响应 ICMP 时间戳请求。
(2)使用 tcpdump
抓包
tcpdump -ni eth0 icmp and icmp[0] == 13 or icmp[0] == 14
- 如果捕获到
ICMP timestamp request/reply
,说明流量未被过滤。
2. 禁用 ICMP 时间戳(Type 13/14)
(1)Linux 系统(iptables/nftables)
方法 1:使用 iptables
(传统方式)
# 屏蔽入站 ICMP 时间戳请求(Type 13)
iptables -A INPUT -p icmp --icmp-type timestamp-request -j DROP
# 屏蔽出站 ICMP 时间戳响应(Type 14)
iptables -A OUTPUT -p icmp --icmp-type timestamp-reply -j DROP
# 保存规则(Debian/Ubuntu)
iptables-save > /etc/iptables/rules.v4
# 保存规则(RHEL/CentOS)
service iptables save
方法 2:使用 nftables
(推荐)
nft add table inet filter
nft add chain inet filter input { type filter hook input priority 0 \; }
nft add chain inet filter output { type filter hook output priority 0 \; }
# 屏蔽 ICMP 时间戳请求和响应
nft add rule inet filter input ip protocol icmp icmp type timestamp-request drop
nft add rule inet filter output ip protocol icmp icmp type timestamp-reply drop
# 持久化规则
nft list ruleset > /etc/nftables.conf
(2)Windows 系统(防火墙)
- 打开高级防火墙设置:
Win + R
→wf.msc
→ 入站规则 → 新建规则。
- 自定义规则:
- 规则类型:
自定义
→所有程序
。 - 协议类型:
ICMPv4
→ 高级 → ICMP 类型 13(请求)和 14(响应)。 - 操作:
阻止连接
。
- 规则类型:
- 应用规则。
(3)云服务器(AWS/Azure/GCP)
- AWS Security Group:
- 入站规则:禁止
ICMP Type 13
。 - 出站规则:禁止
ICMP Type 14
。
- 入站规则:禁止
- Azure NSG:
- 添加规则拒绝
ICMP 13/14
。
- 添加规则拒绝
- GCP 防火墙规则:
- 创建规则拒绝
icmp:13
和icmp:14
。
- 创建规则拒绝
3. 验证是否生效
(1)再次使用 nmap
检测
nmap -Pn --script icmp-timestamp -p 80 your-server.com
预期结果:
- 无
TIMESTAMP REPLY
响应。
(2)使用 ping -T
测试(Linux)
ping -T tsonly your-server.com
预期结果:
- 无响应或
Request timed out
。
(3)检查防火墙日志
# iptables 日志(需先启用日志记录)
grep ICMP /var/log/syslog
# nftables 日志
nft list ruleset | grep 'icmp.*drop'
4. 额外加固建议
✅ 禁用其他不必要的 ICMP 类型(如 echo-reply
可限制)。
✅ 启用防火墙默认拒绝策略:
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT # 允许出站,按需调整
✅ 定期审计网络规则:
iptables -L -v -n | grep icmp
📌 总结
- 检测:用
nmap
或tcpdump
确认 ICMP 时间戳是否开放。 - 修复:通过防火墙(iptables/nftables/云平台)禁用
Type 13/14
。 - 验证:确保无时间戳请求/响应泄露。
修复后,服务器将不再响应 ICMP 时间戳探测,减少信息暴露风险! 🔒