本文档介绍如何使用简单网络管理协议(SNMP)清除路由器中的单个地址解析协议(ARP)条目。
本文档没有任何特定的要求。
本文档中的信息基于支持运行Cisco IOS®软件的RFC1213MIB的所有设备。
本文档中的信息都是基于特定实验室环境中的设备编写的。本文档中使用的所有设备最初均采用原始(默认)配置。如果您使用的是真实网络,请确保您已经了解所有命令的潜在影响。
有关文档规则的详细信息,请参阅 Cisco 技术提示规则。
没有Cisco IOS软件命令可清除单个ARP表条目。Cisco IOS软件clear arp-cache命令可清除整个表。
在MIB对象ipNetToMediaType(.1.3.6.1.2.1.4.22.1.4)的表ipNetToMediaTable(.1.3.6.1.2.1.4.22)中使用SNMPRFC1213 MIB。
.1.3.6.1.2.1.4.22 ipNetToMediaTable OBJECT-TYPE -- FROM RFC1213-MIB DESCRIPTION "The IP Address Translation table used for mapping from IP addresses to physical addresses." ::= { iso(1) org(3) dod(6) internet(1) mgmt(2) mib-2(1) ip(4) 22 } .1.3.6.1.2.1.4.22.1.4 ipNetToMediaType OBJECT-TYPE -- FROM RFC1213-MIB SYNTAX Integer { other(1), invalid(2), dynamic(3), static(4) } MAX-ACCESS read-create STATUS Current DESCRIPTION "The type of mapping. Setting this object to the value invalid(2) has the effect of invalidating the corresponding entry in the ipNetToMediaTable. That is, it effectively disassociates the interface identified with said entry from the mapping identified with said entry. It is an implementation-specific matter as to whether the agent removes an invalidated entry from the table. Accordingly, management stations must be prepared to receive tabular information from agents that corresponds to entries not currently in use. Proper interpretation of such entries requires examination of the relevant ipNetToMediaType object." ::= { iso(1) org(3) dod(6) internet(1) mgmt(2) mib-2(1) ip(4) ipNetToMediaTable(22) ipNetToMediaEntry(1) 4 }
当您运行ansnmpseton MIB对象ipNetToMediaType(.1.3.6.1.2.1.4.22.1.4)到invalid=2时,可以删除单个ARP条目。
注意:确保在路由器上配置SNMP只读(RO)/读写(RW)社区字符串。
以下是路由器上MIB对象ipNetToMediaType的snmpwalk输出:
snmpwalk 172.16.99.1 public .1.3.6.1.2.1.4.22.1.4 ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaType.1.172.16.98.1 = other(1) ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaType.1.172.16.98.2 = dynamic(3) ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaType.2.172.16.98.36 = dynamic(3) ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaType.2.172.16.98.37 = other(1) ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaType.3.172.16.97.1 = other(1) ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaType.3.172.16.97.101 = other(1) ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaType.3.172.16.97.254 = dynamic(3) ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaType.4.172.16.98.41 = dynamic(3) ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaType.4.172.16.98.45 = other(1) ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaType.7.172.16.96.1 = other(1) --<snip>--
当您对一个ARP条目执行snmpset时,例如:
ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaType.1.172.16.98.2 = dynamic(3)
并根据MIB定义将其值设置为2=invalid:
snmpset 172.16.99.1 private ipNetToMediaType.1.172.16.98.2 i 2 ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaType.1.172.16.98.2 = invalid(2)
如果在路由器上执行另一个MIB对象ipNetToMediaType snmpwalk,则会看到以下输出:
snmpwalk 172.16.99.1 public .1.3.6.1.2.1.4.22.1.4 ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaType.1.172.16.98.1 = other(1) ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaType.2.172.16.98.36 = dynamic(3) ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaType.2.172.16.98.37 = other(1) ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaType.3.172.16.97.1 = other(1) ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaType.3.172.16.97.101 = other(1) ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaType.3.172.16.97.254 = dynamic(3) ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaType.4.172.16.98.41 = dynamic(3) ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaType.4.172.16.98.45 = other(1) ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaType.7.172.16.96.1 = other(1) ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaType.7.172.16.96.31 = dynamic(3) ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaType.7.172.16.96.40 = dynamic(3) --<snip>--
目标输出不再在输出中。
ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaType.1.172.16.98.2 = dynamic(3)
以下是对上面使用的变量的说明:
172.16.99.1 =本示例中使用的路由器的IP地址。
private =路由器的RW SNMP社区字符串
public =路由器的RO SNMP社区字符串
.1.3.6.1.2.1.4.22.1.4= MIB对象ipNetToMediaType的对象ID(OID)
i = MIB中定义的SYNTAX的整数
2(无效)= MIB对象的值