File: listening-on-multiple-interfaces.rst

package info (click to toggle)
python-pysnmp4 4.4.6%2Brepack1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,388 kB
  • sloc: python: 19,792; makefile: 166; sh: 23
file content (36 lines) | stat: -rw-r--r-- 1,224 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

Listening on multiple network interfaces
----------------------------------------

Q. 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?

A. 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).

.. code-block:: python

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

    # Setup second transport endpoint
    config.addSocketTransport(
        snmpEngine,
        udp.domainName + (2,),
        udp.UdpSocketTransport().openServerMode(('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.