簡體   English   中英

使用SNMP配置訪問點

[英]Configure an Access point using SNMP

目前,我正在使用.NET 4.5開發C#控制台應用程序,以設置訪問點的一些配置值。 該訪問點在我的本地網絡中。 此外,我正在使用SnmpSharpNet庫發出SNMP請求。 為了發出SNMP請求,我使用了SNMP版本2。

問題是我無法對訪問點執行SET請求,並且總是以“ no-access”(錯誤代碼6)響應。 但是我可以毫無問題地執行GET請求。 我也檢查了MIB文件,並且我將要更改的變量也具有讀寫訪問權限。

這是我寫的代碼。

private static LogFile log;
private static SnmpV2Packet response;
private static UdpTarget target;

static void Main(string[] args)
{
    try
    {
        log = new LogFile(args[0]);
        target = new UdpTarget((IPAddress)new IpAddress("<host address>"));

        Pdu pdu = new Pdu();
        pdu.Type = PduType.Set;
        pdu.VbList.Add(new Oid("1.3.6.1.4.1.2356.11.2.88.2.0"), new Integer32(1111));

        AgentParameters aparam = new AgentParameters(SnmpVersion.Ver2, new OctetString("public"));

        response = (SnmpV2Packet)target.Request(pdu, aparam);

    }
    catch (Exception ex)
    {
        log.LogError("Request failed with the exception " + ex, "Main");
        target.Close();
        return;
    }

    if (response == null)
    {
        log.LogError("Error in SNMP request", "Main");
    }
    else
    {
        //If an incorrect response
        if (response.Pdu.ErrorStatus != 0)
        {
            log.LogError("SNMP agent returned error status " + response.Pdu.ErrorStatus, "Main");
        }
        //If a successful response
        else
        {
            log.LogInfo("Value of the " + response.Pdu[0].Oid.ToString() + "changed to " + response.Pdu[0].Value.ToString(), "Main");
        }
    }

    target.Close();
    log.CloseLogFile();
}

這是與MIB文件中的變量相關的部分

-- {SCALAR} 1.3.6.1.4.1.2356.11.2.88.2
lcsSetupWirelessEpaperPort OBJECT-TYPE
    SYNTAX     Integer32 (0..65535)
    MAX-ACCESS read-write
    STATUS     current
    DESCRIPTION
            "-- empty --"
    ::= { lcsSetupWirelessEpaper 2 }

我在命令行上也使用Net-SNMP也很累。 但結果是一樣的。

有人可以告訴我問題出在哪里,我要指出的重點是什么。

謝謝。

“禁止訪問”(SNMP錯誤代碼6)也可能表示您正在使用的SNMP社區(我猜它是“公共”)沒有寫訪問權限。 例如,監視系統應該能夠讀取(獲取)某些值,但不能寫入(設置)它們。 從安全角度來看,希望使用僅在這種情況下具有讀取訪問權限的SNMP社區。

檢查AP的SNMP社區配置,以確保它具有寫訪問權限。 我建議添加一個具有寫訪問權限的新社區,而不是更改“公共”訪問權限。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM