【问题标题】:SNMP v3 with NET::SNMP working, but snmpwalk/snmpget not?带有 NET::SNMP 的 SNMP v3 工作,但 snmpwalk/snmpget 不工作?
【发布时间】:2012-02-13 20:08:54
【问题描述】:

我有以下(工作的)perl 脚本:

use Net::SNMP;

 # create session to the host
 my ($session, $error) = Net::SNMP->session(
                -hostname => $hostname,
                -version => 'snmpv3',
                -username => 'my_user_name',
                -authkey => 'my_authkey',#actually, here stands the real authkey as configured on the switch
                -privkey => 'my_privkey',#same as on switch
                -authprotocol => 'sha',
                -privProtocol => 'des'
        );
        if (!defined($session)) {
            print $error . "\n";
                last;
        }

        # retrieve a table from the remote agent
        my $result = $session->get_table(
                -baseoid => $MAC_OID
        );

        if (!defined($result)) {
                print $session->error . "\n";
                $session->close;
                last;
        }
#print out the result of the snmp query
#....

现在我想将 snmpwalk 或 snmpget 与相同的键一起使用。为此,我在主目录的 .snmp 中创建了一个 snmp.conf 文件,其内容如下:

defSecurityName my_user_name
defContext ""
defAuthType SHA
defSecurityLevel authPriv
defAuthPassphrase my_auth_key here
defVersion 3
defPrivPassphrase my_privkey here
defPrivType DES

如我所见,我在脚本和 snmpget 中使用了相同的凭据。为什么我会收到 snmpget: Authentication failure (incorrect password, community or key)

【问题讨论】:

  • 我曾经在一家公司工作,使用 Perl 进行多供应商网络管理。我的 0.02 美元是,那里有足够的不一致之处,如果某些东西适用于一个 SNMP 客户端库而不是另一个,你不应该过分惊讶,如果随机设备的 SNMP 代理是一块垃圾,你也不应该感到惊讶。 ;)

标签: perl snmp net-snmp


【解决方案1】:

这取决于您使用的 snmpget 和 snmpset 版本。当我针对基于 C# 的 SNMP 代理 http://sharpsnmplib.codeplex.com 测试旧版本的 net-snmp 时,我注意到对于 SHA 身份验证模式 + DES 隐私模式,一个错误阻止了 net-snmp 命令行工具生成正确的消息字节(加密是错误,因此没有代理可以解密它)。

我的建议是您尝试改用 Net::SNMP,就像您发现的那样,它不受相同错误的影响。

【讨论】:

    【解决方案2】:

    您的问题是您正在使用 Net::SNMP 的身份验证密钥和命令行 net-snmp 工具的密码。根据您的 Net::SNMP 使用情况,您实际上是在使用“本地化”密钥。这意味着您的 snmp.conf 文件的正确标记是:

    defAuthLocalizedKey 0xHEXSTRING
    defPrivLocalizedKey 0xHEXSTRING
    

    有关详细信息,请参阅 snmp.conf 手册页。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-21
      • 1970-01-01
      相关资源
      最近更新 更多