Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transparent proxy client failing to expand macro #38

Open
pshemk opened this issue May 3, 2019 · 3 comments
Open

Transparent proxy client failing to expand macro #38

pshemk opened this issue May 3, 2019 · 3 comments

Comments

@pshemk
Copy link

pshemk commented May 3, 2019

I'm building a transparent proxy setup, where a number of appliances send their traps to snmpfwd, which in turn is supposed to forward them to our NMS, spoofing the source IPs to be those of the appliances (so from NMS perspective they appear to arrive directly from the appliances).
I have the actual forwarding working fine, but when I try to apply the transparent proxy configuration from here.

with client.conf setup like this:

peers-group {
  snmp-engine-id: 0x0102030405070809

  snmp-transport-domain: 1.3.6.1.6.1.1.1
  #snmp-bind-address: 0.0.0.0
  snmp-transport-options: transparent-proxy

  # spoof source IP to the IP of the SNMP manager talking to the server part
  snmp-bind-address: ${snmp-peer-address}

  # time out SNMP request in 1 second
  snmp-peer-timeout: 100
  snmp-peer-retries: 0

  snmp-community-name: public
  snmp-security-name: public
  snmp-security-model: 2
  snmp-security-level: 1

  snmp-peer-address: 172.27.196.227:162
  snmp-peer-id: nms-1
}

And server.conf like this:

snmp-credentials-group {
  snmp-transport-domain: 1.3.6.1.6.1.1.100
  snmp-bind-address: 0.0.0.0:1162
  snmp-transport-options: transparent-proxy

  snmp-engine-id: 0x0102030405070809

  snmp-community-name: public
  snmp-security-name: public

  snmp-security-model: 2
  snmp-security-level: 1

  snmp-credentials-id: snmp-credentials
}

after the client process receives a packet from the server and tries to send it - it dies with:

2019-05-03 02:40:29,830 ERROR poll error: Traceback (most recent call last):
; File "/usr/local/lib/python3.6/site-packages/pysnmp/carrier/asyncore/dispatch.py", line 46, in runDispatcher
use_poll=True, map=self.__sockMap, count=1)
; File "/usr/local/lib/python3.6/asyncore.py", line 207, in loop
poll_fun(timeout, map)
; File "/usr/local/lib/python3.6/asyncore.py", line 188, in poll2
readwrite(obj, flags)
; File "/usr/local/lib/python3.6/asyncore.py", line 123, in readwrite
obj.handle_error()
; File "/usr/local/lib/python3.6/asyncore.py", line 110, in readwrite
obj.handle_write_event()
; File "/usr/local/lib/python3.6/asyncore.py", line 442, in handle_write_event
self.handle_write()
; File "/usr/local/lib/python3.6/site-packages/pysnmp/carrier/asyncore/dgram/base.py", line 149, in handle_write
self.socket, outgoingMessage, transportAddress
; File "/usr/local/lib/python3.6/site-packages/pysnmp/carrier/sockmsg.py", line 108, in sendto
addr = ipaddress.ip_address(_to.getLocalAddress()[0])
; File "/usr/local/lib/python3.6/ipaddress.py", line 54, in ip_address
address)
;ValueError: '${snmp-peer-address}' does not appear to be an IPv4 or IPv6 address
caused by <class 'ValueError'>: '${snmp-peer-address}' does not appear to be an IPv4 or IPv6 address

Which makes me believe that the ${snmp-peer-address} macro is not being expanded.

Am I missing something here?

version:

# snmpfwd-client.py --version
SNMP Proxy Forwarder version 0.4.4, written by Ilya Etingof <[email protected]>
Using foundation libraries: pysnmp 4.4.9, pyasn1 0.4.5.
Python interpreter: 3.6.8 (default, Mar 27 2019, 08:49:59)
[GCC 6.3.0 20170516]
@pshemk pshemk changed the title Transparent proxy client failing expand macro Transparent proxy client failing to expand macro May 3, 2019
@etingof
Copy link
Owner

etingof commented May 3, 2019

Could you please look up this message in the log? Is it present, does it look as expected?

Secondly, looking into the code, could it be that you actually have to use server-snmp-peer-address option in the configuration? Let me know if it works for you - I will update the example.

@pshemk
Copy link
Author

pshemk commented May 6, 2019

Yes, using server-snmp-peer-address did the trick. Thank you.

@pshemk pshemk closed this as completed May 6, 2019
@etingof
Copy link
Owner

etingof commented May 6, 2019

Oh, the example appears misleading! Let me fix the documentation...

Let's keep this issue open as a reminder.

@etingof etingof reopened this May 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants