jrd*_*oko 24 security firewall networking ufw
启用 ufw 和 Tiger 安全审核员后,我看到警告说:
The system accepts ICMP redirection messages
Run Code Online (Sandbox Code Playgroud)
什么是 ICMP 重定向消息?是否应该出于安全目的禁用它们?如果是这样,使用 ufw 防火墙的正确方法是什么?
Man*_*nha 30
在某些情况下,ICMP 数据包可用于攻击网络。虽然这种类型的问题在今天并不常见,但在某些情况下确实会发生此类问题。ICMP 重定向或 ICMP 类型 5 数据包就是这种情况。路由器使用 ICMP 重定向来根据主机选择指定一个网络中更好的路由路径,因此基本上它会影响数据包的路由方式和目的地。
通过 ICMP 重定向,主机可以找出可以从本地网络内部访问哪些网络,以及每个此类网络要使用哪些路由器。安全问题来自这样一个事实,包括ICMP重定向在内的ICMP数据包非常容易伪造,基本上攻击者很容易伪造ICMP重定向数据包。
然后,攻击者基本上可以更改主机的路由表,并在他/她选择的路径上更改指向外部主机的流量;路由器将新路径保持活动状态 10 分钟。由于这一事实以及此类场景中涉及的安全风险,仍然建议禁用来自所有公共接口的 ICMP 重定向消息(忽略它们)。
您需要编辑文件 /etc/sysctl.conf
和改变
###################################################################
# Additional settings - these settings can improve the network
# security of the host and prevent against some network attacks
# including spoofing attacks and man in the middle attacks through
# redirection. Some network environments, however, require that these
# settings are disabled so review and enable them as needed.
#
# Do not accept ICMP redirects (prevent MITM attacks)
#net.ipv4.conf.all.accept_redirects = 0
#net.ipv6.conf.all.accept_redirects = 0
# _or_
# Accept ICMP redirects only for gateways listed in our default
# gateway list (enabled by default)
# net.ipv4.conf.all.secure_redirects = 1
#
# Do not send ICMP redirects (we are not a router)
#net.ipv4.conf.all.send_redirects = 0
Run Code Online (Sandbox Code Playgroud)
到
###################################################################
# Additional settings - these settings can improve the network
# security of the host and prevent against some network attacks
# including spoofing attacks and man in the middle attacks through
# redirection. Some network environments, however, require that these
# settings are disabled so review and enable them as needed.
#
# Do not accept ICMP redirects (prevent MITM attacks)
net.ipv4.conf.all.accept_redirects = 0
net.ipv6.conf.all.accept_redirects = 0
# _or_
# Accept ICMP redirects only for gateways listed in our default
# gateway list (enabled by default)
# net.ipv4.conf.all.secure_redirects = 1
#
# Do not send ICMP redirects (we are not a router)
net.ipv4.conf.all.send_redirects = 0
Run Code Online (Sandbox Code Playgroud)
然后应用上面的内核参数修改:
$ sudo sysctl -p
Run Code Online (Sandbox Code Playgroud)