Question

I create an snmp message (SNMP4J) and I need to set the Read Community Public and the Write Community Private.

From an example the community is set:

// Specify receiver
Address targetaddress = new UdpAddress("10.10.10.10/162");
CommunityTarget target = new CommunityTarget();
target.setCommunity(new OctetString("public"));
target.setVersion(SnmpConstants.version2c);
target.setAddress(targetaddress);

But this doesn't specify if it is the write or read community. Is there no way to define them seperatly?

Was it helpful?

Solution

No,community string are like password, read only community string and read/write community string gives you different access for the device. If you only want to get the value from the device,you use the read only community, if you not only want to get the value and also want to change the value, you must use the read/write community. SNMP4j did not know what kind of the access you want, so it left the choice to you, you cannot set them both.

OTHER TIPS

You are just setting community string to be used in communication with SNMP agent. This is not a set-request which creates new community string on the box (within SNMP agent configuration file). I suppose that your box already have RW private and RO public communities defined already (defaults in most cases). To add new community string you have to send a set-request using enterprise specific OID which adds new community string (if this functionality is supported at all). There is no standard RFC-based MIB which allows on that due to security concerns - anyone can add her/his RW community string and use it for further configuration changes. However, everyone can sniffer SNMPv1 traffic (it is not encrypted!) :-) But if someone may perform man-in-the-middle attack, then there is bigger issue than using unencrypted SNMPv1 only ;-). That's it. If you want to add new community string, then you have to ask for specific MIB tables or scalars your SNMP agent developers, or do it by going directly into device and adding these strings to SNMP agent configuration file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top