Device location in SNMP-based Cisco Network Environment

Source: Internet
Author: User
Tags snmp
Background: 1. The relationship between the IP address and the MAC address in the ARP table of the layer-3 device. 2. the forwarding bridge table of the L2 device stores the correspondence between MAC and forwarding ports. 3. CDP (Cisco Discovery Protocol) is the link layer protocol for discovering adjacent devices between Cisco devices. 4. The forwarding table in the layer-2 module of a layer-3 switch is implemented in a cam table, such as show Cam dynamic. 5. When VLAN is divided, the content of the forwarding table on the Cisco device should be obtained according to the Community String indexing method. 1. obtain the corresponding MAC address based on the IP Address:

You can view the ARP cache table of the system to find the Mac corresponding to an IP address and find ipnettomediaphyaddress (Oid: 1.3.6.1.2.1.4.22.1 ),The following result is displayed:, For example:
Oid: 1.3.6.1.2.1.4.22.1.2.8.127.0.0.2 type: SNMP. snmpoctetstring value: (HEX: 00 06 28 67 05 00)

Oid: 1.3.6.1.2.1.4.22.1.2.10.10.1.3.1 type: SNMP. snmpoctetstring value: (HEX: 00 02 B9 B2 4C 0a)

Oid: 1.3.6.1.2.1.4.22.1.2.10.10.1.3.4 type: SNMP. snmpoctetstring value: (HEX: 00 08 74 9C BD A7)

Oid: 1.3.6.1.2.1.4.22.1.2.10.10.1.3.5 type: SNMP. snmpoctetstring value: (HEX: 00 E0 4C 10 3A D7)

Oid: 1.3.6.1.2.1.4.22.1.2.10.10.1.3.34 type: SNMP. snmpoctetstring value: (HEX: 00 0a E6 64 10 4B)

Oid: 1.3.6.1.2.1.4.22.1.2.10.10.1.3.38 type: SNMP. snmpoctetstring value: (HEX: 00 E0 4C 3C 11 02)

Oid: 1.3.6.1.2.1.4.22.1.2.10.10.1.3.75 type: SNMP. snmpoctetstring value: (HEX: 00 50 22 88 29 F2)

Oid: 1.3.6.1.2.1.4.22.1.2.10.10.1.3.82 type: SNMP. snmpoctetstring value: (HEX: 00 D0 F8 0C BC B8)

You can see an oId like ipnettomediaphyaddress.10.1.3.4, which is followed by 10 after ipnettomediaphyaddress, which refers to the forwarding port index of 10.1.3.4. In this way, the MAC address of 10.1.3.4 is 00: 08: 9C: BD: A7.

2.FindCdpcacheaddress (Oid: 1.3.6.1.4.1.9.9.23.1.2.1.1.4),As follows:

Oid: 1.3.6.1.4.1.9.23.1.2.1.1.4.10.145 type: SNMP. snmpoctetstring value:IncludingC _ (HEX: C0 A8 63 02)

Here C0 A8 63 02 is the hexadecimal representation of the IP address, and the decimal value is 192.168.99.2. The IP address of the layer-3 device is 192.168.99.1. The IP address type can be determined by cdpcacheaddresstype. 10 after cdpcacheaddress refers to ifindex.

3.Search for the bridge table above 192.168.99.2. First, you need to obtain the VLAN list on the device and find the vtpvlanifindex (Oid: 1.3.6.1.4.1.9.46.1.3.1.1.18 ),For example:

Oid: 1.3.6.1.4.1.9.46.1.3.1.1.18.1.1 type: SNMP. snmpinteger value: 6

Oid: 1.3.6.1.4.1.9.46.1.3.1.1.18.1.2 type: SNMP. snmpinteger value: 17

Oid: 1.3.6.1.4.1.9.46.1.3.1.1.18.1.3 type: SNMP. snmpinteger value: 18

The last digit of the oId part refers to the VLAN number, and the oId value refers to the ifindex. You can obtain all the VLAN numbers on the device.

4.Search for a bridge forwarding table. Find dot1dtpfdbaddress (OID:1.3.6.1.2.1.17.4.3.1.1)Here, you need to use Community String Indexing, The forwarding table of a Cisco device for each VLANIs different. In this case, the community name is community @ vlank.Number, such as: public @ 1, public @ 2, public @ 3,Public @ 1 is obtained by default.Location forwarding table. In this caseUntil 10.1.3.4 is found.MacAddress, for example:

Oid: 1.3.6.1.2.1.17.4.3.1.1.0.2.253.21.123.10 type: SNMP. snmpoctetstring value: (HEX: 00 02 FD 15 7b 0a)

Oid: 1.3.6.1.2.1.17.4.3.1.1.0.5.59.18.64.136 type: SNMP. snmpoctetstring value: (HEX: 00 05 3B 12 40 88)

Oid: 1.3.6.1.2.1.17.4.3.1.1.0.5.59.18.65.215 type: SNMP. snmpoctetstring value: (HEX: 00 05 3B 12 41 D7)

Oid: 1.3.6.1.2.1.17.4.3.1.1.0.5.59.18.110.148 type: SNMP. snmpoctetstring value: (HEX: 00 05 3B 12 6e 94)

Oid: 1.3.6.1.2.1.17.4.3.1.1.0.8.116.156.189.167 type: SNMP. snmpoctetstring value: (HEX: 00 08 74 9C BD A7)

FollowDot1dtpfdbaddressNext isMacThe address in decimal format.MacFind the address in the rowDot1dtpfdbport (OID:1.3.6.1.2.1.17.4.3.1.2)For example:

Oid: 1.3.6.1.2.1.17.4.3.1.2.0.2.185.178.76.10 type: SNMP. snmpinteger value: 833

Oid: 1.3.6.1.2.1.17.4.3.1.2.0.2.253.21.123.10 type: SNMP. snmpinteger value: 2

Oid: 1.3.6.1.2.1.17.4.3.1.2.0.5.59.18.64.136 type: SNMP. snmpinteger value: 2

Oid: 1.3.6.1.2.1.17.4.3.1.2.0.8.116.156.189.167 type: SNMP. snmpinteger value: 2

Here is the dot1dtpfdbport and the bridge port is searched in decimal form of the obtained MAC address, and its port index is found based on the port to find dot1dbaseportifindex (OID: 1.3.6.1.2.1.17.4.1.2), for example:

Oid: 1.3.6.1.2.1.17.1.4.1.2.1 type: SNMP. snmpinteger value: 4

Oid: 1.3.6.1.2.1.17.1.4.1.2.2 type: SNMP. snmpinteger value: 5

Oid: 1.3.6.1.2.1.17.1.4.1.2.65 type: SNMP. snmpinteger value: 11

Oid: 1.3.6.1.2.1.17.1.4.1.2.66 type: SNMP. snmpinteger value: 12

Oid: 1.3.6.1.2.1.17.1.4.1.2.67 type: SNMP. snmpinteger value: 13

As shown above, the port index ifindex corresponding to the bridge port is 5. Based on this port, you can easily obtain the port name and description. 5. Obtain the IP address of the vswitch connected to the specified port index based on CDP.

use 2 neutralization method, cdpcacheaddress Add a port index to obtain the network device that is connected to the device. If you cannot find the lower-end network device, you may be connected to the host you want to query or not CDP This is the protocol device. ip address, you can ip repeated 3 The following search process is performed until the connected device cannot be found. You can also go to cdpcachedeviceport . Facilitate the formation of a complete link

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.