we have a unbound python modul up and running which resolves Hostnames like ip-1-2-3-4.some.domain to 1.2.3.4. Currently our environment is Ubuntu 16.04 and unbound 1.5.8.
Since Ubuntu 16.04 is EOL in some months I want to update our Servers to Ubuntu 18.04. But the module is not working anymore.
First it seems that accessing qstate.qinfo.qname_str in operate() doesn't work. I get an error:
error: pythonmod: Exception occurred in function operate, event: module_event_moddone
No big deal since the info could be retrieved from qstate.qinfo.qname_list
But when calling msg.set_return_msg(qstate) with a DNSMessage Object which has the answer appended it always fails (and unbound returns SERVFAIL). I compiled the documentation for unbound 1.6.7 and tried the "Response generation" example without luck.
I both tried python2 and python3 with same results.
With some small modifications I got the module up and running with Ubuntu 20.04 which ships with unbound 1.9.4. This modified version also works with Ubuntu 18.04 and a from source compiled unbound 1.11.0.
I attached the module to this E-Mail. Doing a "dig
I seems I'm missing something since - based on the documentation - I doing it okay __ Has someone experienced something similar with Ubuntu 18.04/unbound 1.6.7?
Thanks in advance and thanks for creating such a lovely software!
Christian
If I try this with the latest version from the code repository, I can
make it work just fine. I guess it would also work with unbound 1.11.0.
It turns out to work just fine with qname_str=qstate.qinfo.qname_str
Also the qnamelisttostr can work with ".".join.
The python_script variable has changed to a config_strlist in the newer
releases, and thus I included something to print that correctly.
The list for that python_script config parameter means you can load
multiple python scripts by having more than one python-script: "file"
line in the config file, and in that order, having more than one
"python" element in the module-config list of modules. For here, it is
only a type change and the script is easily fixed to print that right.
Or print env.cfg.python_script.str the first element in the list.
Perhaps these issues are already fixed as part of Python-3 related fixes
in the code base.
I was able to get the script running with a self compiled Ubuntu 1.6.7 (the version used by Ubuntu 18.04) without any problems (with qstate.qinfo.qname_str) so I think the problem is with the Ubuntu 18.04 package.
The python-unbound package behaves a bit odd - it installs a python2 module but strace shows unbound is using python3. I opened a bug report @ launchpad.net.
Greetings from Hamburg
Christian
Am 05.08.20, 12:35 schrieb "Unbound-users im Auftrag von Wouter Wijngaards via Unbound-users" <unbound-users-bounces@lists.nlnetlabs.nl im Auftrag von unbound-users@lists.nlnetlabs.nl>:
Hi Christian,
If I try this with the latest version from the code repository, I can
make it work just fine. I guess it would also work with unbound 1.11.0.
It turns out to work just fine with qname_str=qstate.qinfo.qname_str
Also the qnamelisttostr can work with ".".join.
The python_script variable has changed to a config_strlist in the newer
releases, and thus I included something to print that correctly.
The list for that python_script config parameter means you can load
multiple python scripts by having more than one python-script: "file"
line in the config file, and in that order, having more than one
"python" element in the module-config list of modules. For here, it is
only a type change and the script is easily fixed to print that right.
Or print env.cfg.python_script.str the first element in the list.
Perhaps these issues are already fixed as part of Python-3 related fixes
in the code base.