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

FQDN - Cannot assign requested address #422

Open
banxavi opened this issue Jun 15, 2022 · 1 comment
Open

FQDN - Cannot assign requested address #422

banxavi opened this issue Jun 15, 2022 · 1 comment

Comments

@banxavi
Copy link

banxavi commented Jun 15, 2022

Hi,

I am using pysnmp library to listen traps sent to my server from FQDN address on port 162. Below is the code for FQDN address. It is taken from official documentation, I also set IP to FQDN. My IP localhost to fqdn.dns.com. Instead of IP address

snmp_engine = engine.SnmpEngine()
config.addTransport(snmp_engine,
udp.domainName,
udp.UdpSocketTransport().openServerMode(('fqdn.dns.com', 162)))

I am getting below error when I run my script

Traceback (most recent call last):

File "/usr/lib/python3/dist-packages/pysnmp/carrier/asyncore/dgram/base.py", line 48, in openServerMode
self.socket.bind(iface)
OSError: [Errno 99] Cannot assign requested address

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "./lib/snmp.py", line 316, in listen_for_traps
udp.UdpSocketTransport().openServerMode(('fqdn.dns.com', 162)))
File "/usr/lib/python3/dist-packages/pysnmp/carrier/asyncore/dgram/base.py", line 50, in openServerMode
raise error.CarrierError('bind() for %s failed: %s' % (iface, sys.exc_info()[1],))
pysnmp.carrier.error.CarrierError: bind() for ('fqdn.dns.com', 162) failed: [Errno 99] Cannot assign requested address

@lextm
Copy link

lextm commented Jan 19, 2023

It makes no sense to bind to your public IP address (usually what you mapped to a domain name), as your machine does not own that IP address.

You are trying to run a trap listener app at port 162, and handle external UDP/SNMP traffic with it. Thus, it should bind to one of the network adapters of this machine, or all of them. For IPv4 scenarios, that means either the private IP address assigned to the adapter (like 192.168.0.x or simply 0.0.0.0).

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