What is the most optimal way to perform a reverse DNS lookup on an IP submitted via a parameter using OpenResty? thanks, - G .
You can use the resty-dns module for this https://github.com/openresty/lua-resty-dns
Regards, Luis On 05/13/2014 05:03 PM, Gordon Madarm wrote: What is the most optimal way to perform a reverse DNS lookup on an IP submitted via a parameter using OpenResty? thanks, - G .
On Tuesday, May 13, 2014 6:07:44 PM UTC+3, Luis Gasca wrote: You can use the resty-dns module for this https://github.com/openresty/lua-resty-dns How? AFAICT from the documentation lua-resty-dns only supports forward lookups. - G Regards, Luis On 05/13/2014 05:03 PM, Gordon Madarm wrote: What is the most optimal way to perform a reverse DNS lookup on an IP submitted via a parameter using OpenResty? thanks, - G .
something like this: local r, err = dns:new{ nameservers = {"208.67.222.222", {"208.67.220.220"} }, retrans = 5, -- 5 retransmissions on receive timeout timeout = 2000, -- 2 sec } local b1, b2, b3, b4 = ip:match("^(%d+)%.(%d+)%.(%d+)%.(%d+)$") local ptr = b4.."."..b3.."."..b2.."."..b1..".in-addr.arpa" local answers, err = r:query(ptr, { qtype = r.TYPE_PTR })
On 05/13/2014 08:19 PM, Gordon Madarm wrote: On Tuesday, May 13, 2014 6:07:44 PM UTC+3, Luis Gasca wrote: You can use the resty-dns module for this https://github.com/openresty/lua-resty-dns How? AFAICT from the documentation lua-resty-dns only supports forward lookups. - G Regards, Luis On 05/13/2014 05:03 PM, Gordon Madarm wrote: What is the most optimal way to perform a reverse DNS lookup on an IP submitted via a parameter using OpenResty? thanks, - G .
On Tuesday, May 13, 2014 9:23:38 PM UTC+3, Luis Gasca wrote: something like this: local r, err = dns:new{ nameservers = {"208.67.222.222", {"208.67.220.220"} }, retrans = 5, -- 5 retransmissions on receive timeout timeout = 2000, -- 2 sec } local b1, b2, b3, b4 = ip:match("^(%d+)%.(%d+)%.(%d+)%.(%d+)$") local ptr = b4.."."..b3.."."..b2.."."..b1..".in-addr.arpa" local answers, err = r:query(ptr, { qtype = r.TYPE_PTR }) Hi Luis, I'm probably missing something obvious but when I use your example and query the ans.name variable using the IP 173.194.34.150 I get 150.34.194.173.in-addr.arpa instead of lhr14s21-in-f22.1e100.net. How can I query an IP address and receive a FQDN in return? Thanks! -G On 05/13/2014 08:19 PM, Gordon Madarm wrote: On Tuesday, May 13, 2014 6:07:44 PM UTC+3, Luis Gasca wrote: You can use the resty-dns module for this https://github.com/openresty/lua-resty-dns How? AFAICT from the documentation lua-resty-dns only supports forward lookups. - G Regards, Luis On 05/13/2014 05:03 PM, Gordon Madarm wrote: What is the most optimal way to perform a reverse DNS lookup on an IP submitted via a parameter using OpenResty? thanks, - G .
Hi, You need to query ans.ptrdname
Luis On 05/14/2014 02:43 PM, Gordon Madarm wrote: On Tuesday, May 13, 2014 9:23:38 PM UTC+3, Luis Gasca wrote: something like this: local r, err = dns:new{ nameservers = {"208.67.222.222", {"208.67.220.220"} }, retrans = 5, -- 5 retransmissions on receive timeout timeout = 2000, -- 2 sec } local b1, b2, b3, b4 = ip:match("^(%d+)%.(%d+)%.(%d+)%.(%d+)$") local ptr = b4.."."..b3.."."..b2.."."..b1..".in-addr.arpa" local answers, err = r:query(ptr, { qtype = r.TYPE_PTR }) Hi Luis, I'm probably missing something obvious but when I use your example and query the ans.name variable using the IP 173.194.34.150 I get 150.34.194.173.in-addr.arpa instead of lhr14s21-in-f22.1e100.net. How can I query an IP address and receive a FQDN in return? Thanks! -G On 05/13/2014 08:19 PM, Gordon Madarm wrote: On Tuesday, May 13, 2014 6:07:44 PM UTC+3, Luis Gasca wrote: You can use the resty-dns module for this https://github.com/openresty/lua-resty-dns How? AFAICT from the documentation lua-resty-dns only supports forward lookups. - G Regards, Luis On 05/13/2014 05:03 PM, Gordon Madarm wrote: What is the most optimal way to perform a reverse DNS lookup on an IP submitted via a parameter using OpenResty? thanks, - G .