禁用 ICMPv6 目标不可达回复

禁用 ICMPv6 目标不可达回复
iptables -I OUTPUT -p icmp --icmp-type destination-unreachable -j DROP

上述命令适用于 IPv4,那么对于 IPv6,应该使用什么命令来丢弃 ICMPv6 目标不可达数据包呢?我尝试使用 ip6tables,但无法获得正确的选项。

ip6tables -I OUTPUT -p icmpv6 <icmpv6 type> -j DROP

应该做什么工作?

答案1

手册iptables-extensions(8)页给出了语法:

   icmp6 (IPv6-specific)
       This extension can be used if  `--protocol  ipv6-icmp'  or  `--protocol
       icmpv6' is specified. It provides the following option:

       [!] --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

您可以使用 列出 ICMPv6 类型ip6tables -p ipv6-icmp -h,如手册页中所述。

Valid ICMPv6 Types:
destination-unreachable
   no-route
   communication-prohibited
   address-unreachable
   port-unreachable
packet-too-big
time-exceeded (ttl-exceeded)
   ttl-zero-during-transit
   ttl-zero-during-reassembly
parameter-problem
   bad-header
   unknown-header-type
   unknown-option
echo-request (ping)
echo-reply (pong)
router-solicitation
router-advertisement
neighbour-solicitation (neighbor-solicitation)
neighbour-advertisement (neighbor-advertisement)
redirect

当然,你不应该尝试阻止这些数据包。这将导致应用程序出现异常行为。

相关内容