如何只允许从 Cisco IOS 路由器发出特定类型的 ICMP 不可达数据包?

网络工程 思科 路由器 安全 国际会议 访问控制
2021-07-10 21:20:01

我有一个 Cisco IOS 路由器,并且只想允许发送 ICMP 数据包类型(类型 8,代码 0 和类型 3,代码 4)。我尝试在连接到 Internet 的接口上放置一个出站 ACL,但我的数据包捕获仍然显示路由器正在向扫描我的系统端口发送所有类型的 ICMP 不可达信息。

我知道有一个“no ip unreachables”接口命令,但这会禁止发送所有类型的 ICMP unreachables。

如何限制路由器发出的 ICMP 不可达的类型?

1个回答

如果要防止 Cisco 路由器中的某个接口无法访问 ICMP,可以使用no ip unreachablesinterface 命令。

要阻止 ICMP 回显请求或回显回复,您可以使用扩展访问列表。你没有给我们你试过的 ACL,所以我们真的不知道你做错了什么。您可能希望停止 ICMP 回显请求入站,而不是 ICMP 回显响应出站。这样,路由器不需要路由请求,请求的目标不需要生成回复,只需让它停止即可。

通常,应在入站应用扩展 ACL,并尽可能靠近源。这可以防止路由器浪费资源路由注定要丢弃的数据包。

就像是:

ip access-list extended STOP_PING_REQUESTS_INBOUND
 remark Deny inbound ICMP echo requests
 deny icmp any any echo
 remark Permit any other inbound traffic
 permit ip any any
!
interface <interface>
 no ip unreachables
 ip access-group STOP_PING_REQUESTS_INBOUND in
!

还有一些特定的 ICMP 不可达消息可以阻止出站 我的 IOS 版本 (15.5) 上的 ICMP 选项列表是:

Router(config-ext-nacl)#deny icmp any any ?
  <0-255>                      ICMP message type
  administratively-prohibited  Administratively prohibited
  alternate-address            Alternate address
  conversion-error             Datagram conversion
  dod-host-prohibited          Host prohibited
  dod-net-prohibited           Net prohibited
  dscp                         Match packets with given dscp value
  echo                         Echo (ping)
  echo-reply                   Echo reply
  fragments                    Check non-initial fragments
  general-parameter-problem    Parameter problem
  host-isolated                Host isolated
  host-precedence-unreachable  Host unreachable for precedence
  host-redirect                Host redirect
  host-tos-redirect            Host redirect for TOS
  host-tos-unreachable         Host unreachable for TOS
  host-unknown                 Host unknown
  host-unreachable             Host unreachable
  information-reply            Information replies
  information-request          Information requests
  log                          Log matches against this entry
  log-input                    Log matches against this entry, including input interface
  mask-reply                   Mask replies
  mask-request                 Mask requests
  mobile-redirect              Mobile host redirect
  net-redirect                 Network redirect
  net-tos-redirect             Net redirect for TOS
  net-tos-unreachable          Network unreachable for TOS
  net-unreachable              Net unreachable
  network-unknown              Network unknown
  no-room-for-option           Parameter required but no room
  option                       Match packets with given IP Options value
  option-missing               Parameter required but not present
  packet-too-big               Fragmentation needed and DF set
  parameter-problem            All parameter problems
  port-unreachable             Port unreachable
  precedence                   Match packets with given precedence value
  precedence-unreachable       Precedence cutoff
  protocol-unreachable         Protocol unreachable
  reassembly-timeout           Reassembly timeout
  redirect                     All redirects
  router-advertisement         Router discovery advertisements
  router-solicitation          Router discovery solicitations
  source-quench                Source quenches
  source-route-failed          Source route failed
  time-exceeded                All time exceededs
  time-range                   Specify a time-range
  timestamp-reply              Timestamp replies
  timestamp-request            Timestamp requests
  tos                          Match packets with given TOS value
  traceroute                   Traceroute
  ttl                          Match packets with given TTL value
  ttl-exceeded                 TTL exceeded
  unreachable                  All unreachables
  <cr>