How can I set the SNMPv3 context

From Net-SNMP Wiki
Jump to: navigation, search
Good Answer

This is a Good Answer article. It was likely created as a response to a question on a Net-SNMP Mailing List and written up here for others to see. It likely covers material not yet in the FAQ or in the Tutorial but may someday be moved there

Question

How can I configure the SNMPv3 contextEngineID or the contextName?

Answer

In the Clients

The clients can use the -N switch to specify the contextName they wish to use, or the -E switch to specify the contextEngineID they wish to use.

The snmp.conf configuration token defaultContext can also be used to specify the contextName that should be used by default.

In the Agent

The contextName used inside the agent (which is what I assume you're talking about) is always the default context name, which is an empty string. The default contextEngineID is the same as the security engine ID for USM.

You can have modules coded to register under different contextNames, but there isn't a configuration method to change the context of the entire agent.

Contexts were really designed to allow talking through an agent to a remote device. You can also use them to distinguish overlapping data. For example, the snmptrapd application registers itself as a subagent using the AgentX protocol underneath the main agent. Because the snmptrapd program also has a user table, it would conflict with the main agent's usmUserTable. So, the snmptrapd subagent registers its own usmUserTable under the context "snmptrapd" instead.

In MIB code

Please see the FAQ entry How can I register a MIB module in a different (SNMPv3) context?