IPv6并非因为缺乏NAT而不安全。
IPv6 is not insecure because it lacks a NAT

原始链接: https://www.johnmaguire.me/blog/ipv6-is-not-insecure-because-it-lacks-nat/

## IPv4 与 IPv6 安全性:揭穿 NAT 的误解 一种常见的观点认为,由于 IPv4 广泛使用网络地址转换 (NAT),IPv4 本质上比 IPv6 更安全。这是一种误解。NAT 的创建是为了解决 IPv4 地址耗尽的问题,*而非*一项安全功能。 虽然 NAT 可以隐藏内部 IP 地址,但人们认为的安全来自于通常包含在 NAT 路由器中的 **有状态防火墙**——而不是 NAT 本身。这些防火墙默认情况下会拒绝入站流量,除非明确允许,此功能与 IP 版本无关。 现代路由器,包括支持 IPv6 的路由器,都采用类似的默认拒绝防火墙规则。要允许 IPv6 中的未经请求的入站流量,您*必须*创建一个特定的防火墙规则,就像使用 IPv4 和 NAT 一样。因此,IPv6 不会因为不依赖 NAT 进行地址共享而变得不安全。安全性依赖于正确的防火墙配置,无论使用哪种 IP 协议。

相关文章

原文

I recently saw a discussion where someone argued that IPv4 is more secure than IPv6 because “the NAT-by-default of IPv4 effectively means that I get the benefit of a default-deny security strategy.” This is a common misconception that I think is worth addressing.

The fundamental issue here is conflating NAT (Network Address Translation) with security. NAT isn’t actually a security feature—it’s an address conservation mechanism that became necessary because we ran out of IPv4 addresses. (Although it is totally possible to use a NAT with IPv6 too!)

NAT allows multiple devices on a home network to share a single IP address on the public Internet by rewriting the destination IP of a packet based on its destination port. It chooses a new destination IP based on the “port mappings” or “port forwards” configured by the network admin.

The consequence of this is that when receiving inbound traffic to a NAT’d IP, packets with an unexpected destination port (one which has not been forwarded) will keep the destination IP of the public machine and will not be routed to another machine on the network.

But the security benefits people attribute to NAT actually come from the stateful firewall that’s typically bundled with NAT routers. Modern routers ship with firewall policies that deny inbound traffic by default, even when a NAT is not being used. The firewall will drop packets with an unexpected destination before even considering whether to rewrite or route the packets. For example, UniFi routers ship with these default IPv6 firewall rules:

  1. Allow Established/Related Traffic (outbound return traffic)
  2. Block Invalid Traffic
  3. Block All Other Traffic

Therefore, in order to allow unsolicited inbound traffic to any IPv6 device hosted behind the router, you must explicitly add a firewall rule to allow the traffic, whether using a NAT or not.

联系我们 contact @ memedata.com