My Linux machine has both IPv4 and IPv6 (dual stack).
When I define trap listener (SNMP class) as IPv4: new DefaultUdpTransportMapping(new UdpAddress(InetAddress.getByName(IPv4),162)), listener not receives traps sent to IPv6 address.
And vice versa, when I define listener as IPv6: new DefaultUdpTransportMapping(GenericAddress.parse(“udp:[”+IPv6+"]/162")), listener not receives traps sent to IPv4 address.
I have tried to define two transport mappings (IPv4 and IPv6) into the same MessageDispatcher and initialize Snmp object with such MessageDispatcher :
MessageDispatcher mtDispatcher =
new MultiThreadedMessageDispatcher(threadPool, new MessageDispatcherImpl());
snmp = new Snmp(mtDispatcher);
But this solution also not works.
I should receive both traps from different senders registered on different IP types of my Linux machine.
At the same station (OS CentOS 7.7) should be installed 2 co-hosted processes with dual stack
definition. Each process should have trap listener and snmp agent on both IPv4 and IPv6 addresses.
Such configuration requires to lookup solution how to define concrete IPs and not to use unspecified address.
Could you advice how to implement such requirement with SNMP4J?
I guess (not more), the approach using two transport mappings (one for IPv4 and one for IPv6) using the same port (162) will not work because the port is bound to TCP or UDP protocol on top of IP. Depending on the architecture of your OS, having two IP addresses (which can be bound to same transport endpoint with the dual-stack feature) with the same port will cause a port clash and only one of them (the first listening) will work.
I think you need to investigate deeply how your IP stack works and then find the a matching setup for it.
I have done a lot of experiments on our dual stack system.
I understood that if I define all IPs “::” or local IPv6 as listener IP,
listener receives only traps from IPv6 clients and not receives traps from IPv4 clients.
This problem is critical for us.
May be you will recommend some solution?
As I wrote above, with SNMP4J you can simply use two different IP addresses (regardless if IPv4 or IPv6) and use each of them for a corresponding TransportMapping. That will work if the underlying Java works with the underlying IP stack of the operating system as you expect it.
I cannot give any other advise than this, sorry. Maybe you are trying to accomplish something that cannot be done with your system architecture?