显示arp时如何匹配条件?

网络工程 思科 arp
2021-07-05 09:48:48

在我的 Cisco 路由器中,我检查了 arp:

Router>show arp 
Protocol  Address          Age (min)  Hardware Addr   Type   Interface
Internet  192.168.1.1             -   0001.42D2.AE01  ARPA   GigabitEthernet0/0/0
Internet  192.168.1.2             67  000C.CF4C.99E6  ARPA   GigabitEthernet0/0/0
Internet  192.168.2.1             -   0001.42D2.AE02  ARPA   GigabitEthernet0/0/1
Internet  192.168.2.2             109 0010.114E.A4EC  ARPA   GigabitEthernet0/0/1

我想匹配条件,但我试过了,都不起作用:

Router>show arp | match 192.168.2.2
                ^
% Invalid input detected at '^' marker.

Router>show arp 192.168.2.2
                ^
% Invalid input detected at '^' marker.

我也试过开始,或者包括:

Router#show arp | begin ?
% Unrecognized command

更新

show version显示此:

Cisco IOS XE Software, Version 03.16.05.S - Extended Support Release
Cisco IOS Software, ISR Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version Version 15.5 (3)S5, RELEASE SOFTWARE (fc2)

这是一个 ISR 4321 路由器。

2个回答

适用于大多数 Cisco IOS。 (对于 ISR 4321,答案似乎有所不同,见下文。)

要开始匹配,请使用| begin

gw>show arp | begin 192.168.0.32
Internet  192.168.0.32            0   90fb.a630.1234  ARPA   Vlan1
Internet  192.168.0.36            0   0004.2012.4321  ARPA   Vlan1
...

有几个品种:

gw>show arp | ?
  begin    Begin with the line that matches
  count    Count number of lines which match regexp
  exclude  Exclude lines that match
  format   Format the output using the specified spec file
  include  Include lines that match
  section  Filter a section of output

但是如果你不能做基本的事情,就会发生一些有趣的事情:

gw>show arp 192.168.0.32
Protocol  Address          Age (min)  Hardware Addr   Type   Interface
Internet  192.168.0.32            0   90fb.a630.1234  ARPA   Vlan1

您使用的是什么型号和版本?

ISR-4321

根据Cown 的评论:

好的,我发现了我认为的错误,您需要使用 show ip arp | 在 192.168.2.2

数据包追踪器

正如 Cown 在评论中所建议的那样,如果您使用的是 Packet Tracer,而不是真正的路由器,则必须处于启用模式。

使用下面提到的命令将 ARP 关联与 ip 地址匹配

Layer3device(config)#sh ip arp | i 192.168.2.2

如果要显示设备上的所有 ARP 表,请使用 fallowing 命令

Layer3device(config)#Sh ip arp

从这份ARP表列表中。特定的 ip 地址和关联的 mac 地址是可见的。