I create snmp trap receiver using snmp4j. I managed to receive the pdu and process it. I need the targeted ip address as my machine have multiple ip addresses. I could thinking either two ways:
event.getTransportMapping().getListenAddress()
but getting 0.0.0.0/161 as I need to listen to many ip address. Used event.getPeerAddress()
but getting ip address of the sender's machine.Really appreciate for any kind of help. Thanks in advance.
Solved by:
UdpAddress udpHostAdress = (UdpAddress) cmdRespEvent.getTransportMapping().getListenAddress();
String ipAdd = udpHostAdress.getInetAddress().getHostAddress();
System.out.println("Target IP = " + ipAdd);