我无法在 cisco 交换机 2960 上请求 GigabitEthernet 接口。
当我执行时:
use Net::SNMP;
use Net::SNMP::Interfaces;
my $interfaces = Net::SNMP::Interfaces->new(Hostname => $hostname, Community => $community);
my @inter = $interfaces->all_interfaces();
my $it;
for my $i (@inter) {
my $it = $i->ifDescr();
print $i->name()."\n";
}
我得到输出:
FastEthernet0/1
FastEthernet0/2
FastEthernet0/3
...
FastEthernet0/23
FastEthernet0/24
GigabitEthernet0/1
GigabitEthernet0/2
所以,到目前为止,一切正常。
我得到了 GigabitEthernet 接口的 ifIndex(例如 GigabitEthernet0/2):
my $in = $interfaces->interface("GigabitEthernet0/2");
print "INDEX:".$in->index()."\n";
它返回:
INDEX:10102
所以,我知道我的界面的 ifIndex 。
但我也需要获取 VLAN,以获取有关连接到此接口的速度、别名、双工、mac 地址的信息......
从这里开始问题:
#Listing all VLANS
my $vmVlan = "1.3.6.1.4.1.9.9.68.1.2.2.1.2";
my $vlans = SnmpUtil->new($hostname, $community);
my %vl = $vlans->requeteTable($vmVlan);
foreach my $k (keys(%vl)) {
print "Clef=$k Valeur=$vl{$k}\n";
}
它显示:
...
Clef=10013 Valeur=1
Clef=10011 Valeur=1
Clef=10014 Valeur=1
Clef=10002 Valeur=10
...
但是 GigabitEthernet0/2 (10102) 的 ifIndex 不在此哈希中...
所以我找不到 VLAN。
如何获取 GigabitEthernet 接口的所有信息?其他解决方案?需要帮助,大奖励!
编辑:
找到解决方案,GigabitEhernet 端口似乎在 VLAN 1 上,即使它们没有出现在 lising vlan 中。