如何通过MIB读取VPN、接口、IP地址对应关系:
我们需要用到如下几个MIB节点:
1、ifTable表单中的ifDescr (1.3.6.1.2.1.2.2.1.2)节点,用于获取接口索引与接口对应关系。
OID of this table is: 1.3.6.1.2.1.2.2
Name |
Access |
PDS |
Description |
ifIndex (1.3.6.1.2.1.2.2.1.1) |
read-only |
Current |
As per MIB |
ifDescr (1.3.6.1.2.1.2.2.1.2) |
read-only |
No |
A textual string containing information about the interface. Such as null0, Vlan-interface2, Gigabitethernet1/0/1 |
2、hh3cIpAddrReadTable表单中的hh3cIpAddrReadAddrType(1.3.6.1.4.1.25506.2.67.1.1.2.1.2)节点用于获取索引对应IP地址。
OID of this table is: 1.3.6.1.4.1.25506.2.67.1.1.2
Name |
Access |
PDS |
Description |
hh3cIpAddrReadIfIndex (1.3.6.1.4.1.25506.2.67.1.1.2.1.1) |
not-accessible |
Current |
As per MIB |
hh3cIpAddrReadAddrType (1.3.6.1.4.1.25506.2.67.1.1.2.1.2) |
not-accessible |
Current |
Only support ipv4(1) |
hh3cIpAddrReadAddr (1.3.6.1.4.1.25506.2.67.1.1.2.1.3) |
not-accessible |
Current |
As per MIB |
hh3cIpAddrReadMask (1.3.6.1.4.1.25506.2.67.1.1.2.1.4) |
read-only |
Current |
As per MIB |
hh3cIpAddrReadSourceType (1.3.6.1.4.1.25506.2.67.1.1.2.1.5) |
read-only |
Current |
As per MIB |
3、hh3cIpv4AddrTable表单中的hh3cIpv4AddrAddr 1.3.6.1.4.1.25506.2.67.1.1.3.1.1节点也可以用于获取索引对应IP地址。
OID of this table is: 1.3.6.1.4.1.25506.2.67.1.1.3
Name |
Access |
PDS |
Description |
hh3cIpv4AddrAddr (1.3.6.1.4.1.25506.2.67.1.1.3.1.1) |
read-create |
Current |
When reading, the value will be 0.0.0.0 if no primary IP address exists on the interface. |
hh3cIpv4AddrMask (1.3.6.1.4.1.25506.2.67.1.1.3.1.2) |
read-create |
Current |
As per MIB |
hh3cIpv4AddrRowStatus (1.3.6.1.4.1.25506.2.67.1.1.3.1.3) |
read-create |
Current |
Only support active(1), notInService(2), createAndGo(4) and destroy(6) , When reading, the value is active(1) if exists a primary IP address on the interface. When reading, the value is notInService (2) if no primary IP address exists on the interface. |
4、mplsL3VpnIfConfTable中的mplsL3VpnIfVpnClassification节点1.3.6.1.2.1.10.166.11.1.2.1.1.2用户获取VPN与接口索引对应关系:
OID of this table is: 1.3.6.1.2.1.10.166.11.1.2.1
Name |
Access |
PDS |
Description |
mplsL3VpnIfConfIndex(1.3.6.1.2.1.10.166.11.1.2.1.1.1) |
not-accessible |
No |
As per MIB |
mplsL3VpnIfVpnClassification(1.3.6.1.2.1.10.166.11.1.2.1.1.2) |
read-create |
No |
Only support read |
mplsL3VpnIfVpnRouteDistProtocol (1.3.6.1.2.1.10.166.11.1.2.1.1.3) |
read-create |
No |
Only support read |
mplsL3VpnIfConfStorageType (1.3.6.1.2.1.10.166.11.1.2.1.1.4) |
read-create |
No |
Only support read
|
mplsL3VpnIfConfRowStatus (1.3.6.1.2.1.10.166.11.1.2.1.1.5) |
read-create |
No |
As per MIB |
举例读取如下:
S125X-AF设备,配置了VPN XX,Ten-GigabitEthernet 2/3/0/11.1绑定了该VPN并且配置了IP地址201.1.2.2。
配置如下:
[2012-125X-AF]dis ip vpn-instance
Total VPN-Instances configured : 1
VPN-Instance Name RD Create time
xx 1:2 2025/11/30 00:12:00
[2012-125X-AF]display current-configuration interface Ten-GigabitEthernet 2/3/0/11.1
#
interface Ten-GigabitEthernet2/3/0/11.1
ip binding vpn-instance xx
ip address 201.1.2.2 255.255.255.0
#
return
读取举例如下:
1、读取接口索引对应关系,Ten-GigabitEthernet2/3/0/11.1接口索引为46504
PS C:\Users\Administrator\Desktop\snmpwalk> .\snmpwalk.exe -c public -v 2c 192.168.89.12 1.3.6.1.2.1.2.2.1.2
iso.3.6.1.2.1.2.2.1.2.5785 = STRING: "Ten-GigabitEthernet2/0/0/1"
iso.3.6.1.2.1.2.2.1.2.5786 = STRING: "Ten-GigabitEthernet2/0/0/2"
iso.3.6.1.2.1.2.2.1.2.5787 = STRING: "Ten-GigabitEthernet2/0/0/3"
iso.3.6.1.2.1.2.2.1.2.5788 = STRING: "Ten-GigabitEthernet2/0/0/4"
iso.3.6.1.2.1.2.2.1.2.5789 = STRING: "Ten-GigabitEthernet2/0/0/5"
iso.3.6.1.2.1.2.2.1.2.5790 = STRING: "Ten-GigabitEthernet2/0/0/6"
iso.3.6.1.2.1.2.2.1.2.5791 = STRING: "Ten-GigabitEthernet2/0/0/7"
iso.3.6.1.2.1.2.2.1.2.5792 = STRING: "Ten-GigabitEthernet2/0/0/8"
iso.3.6.1.2.1.2.2.1.2.5793 = STRING: "Ten-GigabitEthernet2/0/0/9"
iso.3.6.1.2.1.2.2.1.2.5794 = STRING: "Ten-GigabitEthernet2/0/0/10"
iso.3.6.1.2.1.2.2.1.2.5795 = STRING: "Ten-GigabitEthernet2/0/0/11"
iso.3.6.1.2.1.2.2.1.2.5796 = STRING: "Ten-GigabitEthernet2/0/0/12"
iso.3.6.1.2.1.2.2.1.2.46504 = STRING: "Ten-GigabitEthernet2/3/0/11.1"
2、获取接口索引与IP地址对应关系,46504索引接口对应IP地址为201.1.2.2,掩码为255.255.255.0,前面1表示地址类型为IPV4,4表示IPV4长度为4字节。
PS C:\Users\Administrator\Desktop\snmpwalk> .\snmpwalk.exe -c public -v 2c 192.168.89.12 1.3.6.1.4.1.25506.2.67.1.1.2.1.4
iso.3.6.1.4.1.25506.2.67.1.1.2.1.4.46475.1.4.1.1.1.1 = IpAddress: 255.255.255.0
iso.3.6.1.4.1.25506.2.67.1.1.2.1.4.46480.1.4.12.1.1.2 = IpAddress: 255.255.255.0
iso.3.6.1.4.1.25506.2.67.1.1.2.1.4.46504.1.4.201.1.2.2 = IpAddress: 255.255.255.0
iso.3.6.1.4.1.25506.2.67.1.1.2.1.4.46537.1.4.10.29.0.33 = IpAddress: 255.255.255.192
iso.3.6.1.4.1.25506.2.67.1.1.2.1.4.46537.1.4.10.29.0.129 = IpAddress: 255.255.255.224
iso.3.6.1.4.1.25506.2.67.1.1.2.1.4.46538.1.4.10.29.0.97 = IpAddress: 255.255.255.192
也可以通过另外一个节点获取地址和索引对应关系
PS C:\Users\Administrator\Desktop\snmpwalk> .\snmpwalk.exe -c public -v 2c 192.168.89.12 1.3.6.1.4.1.25506.2.67.1.1.3.1.1
iso.3.6.1.4.1.25506.2.67.1.1.3.1.1.6518 = IpAddress: 201.1.1.2
iso.3.6.1.4.1.25506.2.67.1.1.3.1.1.6519 = IpAddress: 192.168.12.1
iso.3.6.1.4.1.25506.2.67.1.1.3.1.1.46273 = IpAddress: 0.0.0.0
iso.3.6.1.4.1.25506.2.67.1.1.3.1.1.46504 = IpAddress: 201.1.2.2
iso.3.6.1.4.1.25506.2.67.1.1.3.1.1.46537 = IpAddress: 10.29.0.33
3、通过L3VPN节点获取接口索引与VPN对应关系,46504对应接口索引,120.120对应VPN名称,这里注意下,需要进行ASCII码翻译,120的ASCII码对应为X,120.120对应的VPN名称为XX。
PS C:\Users\Administrator\Desktop\snmpwalk> .\snmpwalk.exe -c public -v 2c 192.168.89.12 1.3.6.1.2.1.10.166.11.1.2.1.1.2
iso.3.6.1.2.1.10.166.11.1.2.1.1.2.2.120.120.46475 = INTEGER: 2
iso.3.6.1.2.1.10.166.11.1.2.1.1.2.2.120.120.46504 = INTEGER: 2
无
✖
案例意见反馈
亲~登录后才可以操作哦!
确定你的邮箱还未认证,请认证邮箱或绑定手机后进行当前操作
过程分析不是读取了么。。看一下哦