Skip to content
Back to top
View this page
Edit this page

# Listening on multiple network interfaces

17. I need my receiving entity (CommandResponder or Notification Receiver) to listen for SNMP messages on multiple network interfaces. How do I do that with pysnmp?

1. Simply register multiple network transports with your SNMP engine. Each transport would be bound to an individual local transport endpoint (for instance, IP address & UDP port pair).

     # Security setup would follow
     ...
     # Setup first transport endpoint
     config.add_socket_transport(
         snmpEngine,
         udp.domainName + (1,),
         udp.UdpSocketTransport().open_server_mode(('127.0.0.1', 162))
     )

     # Setup second transport endpoint
     config.add_socket_transport(
         snmpEngine,
         udp.domainName + (2,),
         udp.UdpSocketTransport().open_server_mode(('192.168.1.1', 162))
     )
     # Receiver callback function implementation and Dispatcher invocation
     # would follow
     ...

    Notice extended transport domain specification (udp.domainName) in
    the code above. There we register each transport endpoint under distinct
    OID, however always within the canonical transport domain OID.