Search code examples
portsnmpnet-snmp

Specify port when using snmptrap


I am trying to specify the port when I am sending a trap via snmptrap. Just in order to test my SNMP receiver I want to send traps to it, but I do not have access to port 162. How do I send the trap to another port?

As I see it the man-page does not describe this option.

(I do not fully understand what the parts of a snmptrap message is either, so if someone feels like explaining that it would be nice to)


Solution

  • In the net-snmp command line tools, you specify the port number in the host identifier, like so:

    192.168.1.12:162
    

    At least, that works on my machine.

    I agree that this is not really apparent from the man page of snmptrap, so I understand why you couldn't figure it out. The rest of the format is, however, described in the man page to a somewhat satisfactory extent.

    Edit: As was pointed out in the comment, the address format is described on the man page for snmpcmd: http://www.net-snmp.org/docs/man/snmpcmd.html