[Pdns-dev] lua script to synthesize AAAA record from A record

Muntasir Rahman muntasir.rahman at gmail.com
Fri May 4 15:47:26 CEST 2012


Hello Peter,
I have solved it, after several minutes learning lua syntax, and examining
pdns_recursor.cc,

1 function nodata (remoteip, domain, qtype, records)
2    print("nodata : ", remoteip, domain, qtype, records)
3    if qtype ~= pdns.AAAA then return -1,{} end
4    setvariable()
5    return getFakeAAAARecords (domain, "0:0:0:0:0:ffff:0:0")
6 end

I modified line 6 to
*return getFakeAAAARecords (domain, "0:0:0:0:0:ffff:0:0")
*previously:
return "getFakeAAAARecords, domain, "0:0:0:0:0:ffff:0:0"

I suggest minor correction at powerdns-example-script.lua as above
http://wiki.powerdns.com/trac/browser/trunk/pdns/pdns/powerdns-example-script.lua

Regards,
Muntasir

On Fri, May 4, 2012 at 7:55 PM, Muntasir Rahman
<muntasir.rahman at gmail.com>wrote:

> Hello Peter,
> Thanks for the clue. I have tried it. But, it return an error message like
> this: PANIC: unprotected error in call to Lua API.
>
> I download the source, with lua hook to nodata function from here:
> http://svn.powerdns.com/snapshots/pdns-recursor-3.3-hooks.tar.bz2
>
> i compile & run it using these steps:
> $ LUA=1 ./configure
> $ LUA=1 make
> ./pdns_recursor --local-address=0.0.0.0 --local-port=5300 --daemon=no
> --socket-dir=./ --lua-dns-script=dns64.lua
>
> Here is the lua script (copy-paste from
> http://wiki.powerdns.com/trac/browser/trunk/pdns/pdns/powerdns-example-script.lua
> ):
>
> function nodata (remoteip, domain, qtype, records)
>     print("nodata : ", remoteip, domain, qtype, records)
>
>     if qtype ~= pdns.AAAA then return -1,{} end
>     setvariable()
>     return "getFakeAAAARecords", domain, "0:0:0:0:0:ffff:0:0"
> end
>
> At a terminal, i launch this command:
> dig @127.0.0.1 -p 5300 www.kame.com AAAA
>
> Aand i got this error message at recursor's terminal:
> PANIC: unprotected error in call to Lua API (attempt to index a nil value)
>
> Would you like to give me a hint on what is wrong with the script?
>
> Regards,
> Muntasir
>
>
> On Fri, May 4, 2012 at 5:42 PM, Peter van Dijk <
> peter.van.dijk at netherlabs.nl> wrote:
>
>> Hello Muntasir,
>>
>> On May 4, 2012, at 6:47 , Muntasir Rahman wrote:
>>
>> > function nodata ( remoteip, domain, qtype, records )
>> >     print ("nodata called for: ", remoteip, getlocaladdress(), domain,
>> qtype)
>> >     if qtype ~= pdns.AAAA then return -1, {} end  --  only AAAA records
>> >     setvariable()
>> >     return "getFakeAAAARecords", domain, "fe80::21b:77ff:0:0" -- here i
>> need to return ::ffff:ipv4.dotted.decimal.format
>> > end
>> >
>> > I would like to do something like this
>> >
>> >     ipv4 = "1.2.3.4" -- how do i get this data from recursor ???
>> >     ipv6 = "::ffff:" .. ipv4  -- synthesized representation of IPv4 in
>> IPv6
>> >     return "getFakeAAARecords", domain, ipv6
>> >
>> > My question is:
>> > - how do i get IPv4 data using lua API in above script examples?
>>
>> You don't. getFakeAAAARecords handles this. Just returning
>> "getFakeAAAARecords", domain, "0:0:0:0:0:ffff:0:0" should work.
>>
>> (You can't say "::ffff" or "::ffff:" - the first would cause the v4
>> address to just overwrite those bits and the last would be a parse error).
>>
>> Kind regards,
>> --
>> Peter van Dijk
>> Netherlabs Computer Consulting BV - http://www.netherlabs.nl/
>>
>> _______________________________________________
>> Pdns-dev mailing list
>> Pdns-dev at mailman.powerdns.com
>> http://mailman.powerdns.com/mailman/listinfo/pdns-dev
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.powerdns.com/pipermail/pdns-dev/attachments/20120504/c2b39d6f/attachment.htm>


More information about the Pdns-dev mailing list