[Pdns-users] Struggel with the Lua Record function 'ifurlup'

Ambauen Daniel (ID) daniel.ambauen at id.ethz.ch
Thu Jun 1 09:08:39 UTC 2023


Hi,

I am trying to familiarize myself with the behavior of Lua Records. 
Except for the 'ifurlup(url, addresses[, options])' function, I was able to follow the examples in the documentation in our Lab. 
https://doc.powerdns.com/authoritative/lua-records/index.html

Now I'm struggling with the 'ifurlup(url, addresses[, options])' function.

This is my Lua record:
ldapmaster.lua.ethz.ch 60 IN LUA A "ifurlup('http://ldapsmaster1.ethz.ch/check.html', {{'129.132.65.36'}, {'129.132.183.152'}})"

If the URL http://ldapsmaster1.ethz.ch/check.html responds with a 200 response code, I expect the following DNS response:
ldapmaster.lua.ethz.ch.	60 IN A 129.132.65.36  

If the URL http://ldapsmaster1.ethz.ch/check.html responds with a 404 response code, I expect the following DNS response:
ldapmaster.lua.ethz.ch.	60 IN A 129.132.183.152 

Unfortunately, the DNS responses are inconsistent:
$ dig @127.1 ldapmaster.lua.ethz.ch +short
129.132.65.36
$ dig @127.1 ldapmaster.lua.ethz.ch +short
129.132.183.152
$ dig @127.1 ldapmaster.lua.ethz.ch +short
129.132.65.36
$ dig @127.1 ldapmaster.lua.ethz.ch +short
129.132.183.152
$ dig @127.1 ldapmaster.lua.ethz.ch +short
129.132.65.36
$ dig @127.1 ldapmaster.lua.ethz.ch +short
129.132.183.152
$ dig @127.1 ldapmaster.lua.ethz.ch +short
129.132.65.36
$ dig @127.1 ldapmaster.lua.ethz.ch +short
129.132.65.36
$ dig @127.1 ldapmaster.lua.ethz.ch +short
129.132.65.36
$ dig @127.1 ldapmaster.lua.ethz.ch +short
129.132.65.36
$ dig @127.1 ldapmaster.lua.ethz.ch +short
129.132.183.152


Tcpdump clearly shows that the web server responds with a 404 response code

tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on ens192, link-type EN10MB (Ethernet), capture size 262144 bytes
09:59:38.533784 IP 172.20.8.116.33260 > 129.132.65.36.80: Flags [P.], seq 1:113, ack 1, win 229, options [nop,nop,TS val 620276954 ecr 3324300551], length 112: HTTP: GET /check.html HTTP/1.1
09:59:38.534502 IP 129.132.65.36.80 > 172.20.8.116.33260: Flags [P.], seq 1:376, ack 113, win 227, options [nop,nop,TS val 3324300553 ecr 620276954], length 375: HTTP: HTTP/1.1 404 Not Found
09:59:43.532520 IP 172.20.8.116.48350 > 129.132.65.36.80: Flags [P.], seq 1:113, ack 1, win 229, options [nop,nop,TS val 620281952 ecr 3324305551], length 112: HTTP: GET /check.html HTTP/1.1
09:59:43.533344 IP 129.132.65.36.80 > 172.20.8.116.48350: Flags [P.], seq 1:376, ack 113, win 227, options [nop,nop,TS val 3324305552 ecr 620281952], length 375: HTTP: HTTP/1.1 404 Not Found
09:59:48.533005 IP 172.20.8.116.48354 > 129.132.65.36.80: Flags [P.], seq 1:113, ack 1, win 229, options [nop,nop,TS val 620286953 ecr 3324310552], length 112: HTTP: GET /check.html HTTP/1.1
09:59:48.534626 IP 129.132.65.36.80 > 172.20.8.116.48354: Flags [P.], seq 1:376, ack 113, win 227, options [nop,nop,TS val 3324310554 ecr 620286953], length 375: HTTP: HTTP/1.1 404 Not Found
09:59:53.532831 IP 172.20.8.116.60652 > 129.132.65.36.80: Flags [P.], seq 1:113, ack 1, win 229, options [nop,nop,TS val 620291953 ecr 3324315552], length 112: HTTP: GET /check.html HTTP/1.1
09:59:53.533388 IP 129.132.65.36.80 > 172.20.8.116.60652: Flags [P.], seq 1:376, ack 113, win 227, options [nop,nop,TS val 3324315552 ecr 620291953], length 375: HTTP: HTTP/1.1 404 Not Found

Why does my example not work as expected?
I must be missing something, am I misunderstanding the docu?


My lua zone lua.ethz.ch <http://lua.ethz.ch/>:

$ORIGIN .
latlon.lua.ethz.ch	60	IN	LUA	TXT "latlon()"
latlon.lua.ethz.ch	60	IN	LUA	LOC "latlonloc()"
ldapmaster.lua.ethz.ch	60	IN	LUA	A "ifurlup('http://ldapsmaster1.ethz.ch/check.html', {{'129.132.65.36'}, {'129.132.183.152'}})"
lua.ethz.ch	86400	IN	NS	ns2.ethz.ch.
lua.ethz.ch	86400	IN	NS	ns1.ethz.ch.
lua.ethz.ch	3600	IN	SOA	soa-ns.ethz.ch hostmaster.ethz.ch 2 10800 3600 604800 300
whoami-ecs.lua.ethz.ch	60	IN	LUA	TXT "'ip: '..who:toString()..', netmask: '..(ecswho and ecswho:toString() or 'no ECS')"
whoami.lua.ethz.ch	60	IN	LUA	TXT "who:toString()"
whoami-port.lua.ethz.ch	60	IN	LUA	TXT "who:toStringWithPort()"
whoami.v4.lua.ethz.ch	60	IN	LUA	TXT "who:toString()"
whoami.v4.lua.ethz.ch	60	IN	LUA	A "who:toString()"
whoami.v6.lua.ethz.ch	60	IN	LUA	TXT "who:toString()"
whoami.v6.lua.ethz.ch	60	IN	LUA	AAAA "who:toString()"



My pdns.conf:

config-dir=/etc/pdns
setuid=pdns
setgid=pdns
8bit-dns=yes
allow-axfr-ips=127.0.0.0/8,172.20.7.128/25,::1
api=yes
api-key=xxxxxxxxxxxxxxxxxxxxxx
cache-ttl=10
consistent-backends=yes
default-api-rectify=yes
default-soa-content=a.misconfigured.dns.server.invalid hostmaster.@ 0 10800 3600 604800 3600
default-soa-edit=INCREASE
default-soa-edit-signed=INCREMENT-WEEKS
default-ttl=3600
distributor-threads=3
enable-lua-records=yes
local-address=0.0.0.0, ::
local-port=53
loglevel=5
max-queue-length=100000
only-notify=
primary=yes
receiver-threads=4
reuseport=yes
secondary=no
server-id=ansp1-in-dvc
webserver=yes
webserver-address=127.0.0.1
webserver-allow-from=127.0.0.1,::1
webserver-loglevel=none
webserver-max-bodysize=2
webserver-port=8081
launch=gpgsql



Kind regards
Daniel






-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4139 bytes
Desc: not available
URL: <http://mailman.powerdns.com/pipermail/pdns-users/attachments/20230601/d2b55d70/attachment.bin>


More information about the Pdns-users mailing list