使用简单网络管理协议(SNMP),本文描述如何清除在路由器的单个地址解析服务(ARP)条目。
本文档没有任何特定的要求。
本文档中的信息根据支持运行Cisco IOS软件的RFC1213MIB的所有设备。
本文档中的信息都是基于特定实验室环境中的设备编写的。本文档中使用的所有设备最初均采用原始(默认)配置。如果您使用的是真实网络,请确保您已经了解所有命令的潜在影响。
有关文档规则的详细信息,请参阅 Cisco 技术提示规则。
没有Cisco IOS软件命令清除单个ARP表条目。clear arp-cache命令的Cisco IOS软件收拾整个桌子。
您能以MIB对象ipNetToMediaType (.1.3.6.1.2.1.4.22.1.4)使用SNMP在tableipNetToMediaTable (.1.3.6.1.2.1.4.22)内从RFC1213MIB。
.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 Read-Only(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>--
当您执行一snmpset对一ARP条目,例如:
ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaType.1.172.16.98.2 = dynamic(3)
并且设置其值为2=invalid,根据MIB定义:
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地址。
私有=路由器的RW SNMP团体字符串
公共=路由器的RO SNMP团体字符串
MIB对象ipNetToMediaType的.1.3.6.1.2.1.4.22.1.4= Object ID (OID)
我=整数作为在MIB的定义语法
2 (无效) = MIB对象的值