Specify port when using snmptrap

Atonic picture Atonic · Jun 12, 2014 · Viewed 7.6k times · Source

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)

Answer

Jolta picture Jolta · Jun 13, 2014

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