Dear all,

I'm trying to show host names (rather than IP addresses, if available)
in dnsmasq's log for A and AAAA queries, as well as for the forward
destinations, i.e. I want to replace

Feb  4 18:02:22 dnsmasq[14001]: query[A] from
Feb  4 18:02:22 dnsmasq[14001]: forwarded to 2620:fe::fe


Feb  4 18:02:22 dnsmasq[14001]: query[A] from
Feb  4 18:02:22 dnsmasq[14001]: forwarded to

For doing this, I tried various attempts:

Firstly, I tried a simple approach using gethostbyaddr() to resolve the
IP addresses to host names. Unfortunately, it seems like gethostbyaddr()
cannot be used inside the DNS resolver process itself, as it always
immediately fails with Unknown host (error code 1) for everything (incl.
e.g. I know that this would have some drawbacks (like
causing a PTR request on every logging), but I would have solved them
with various tricks like building my own lookup tables, etc. I tested my
code in a small standalone application and here name resolution works

Secondly, I build a wrapper around dnsmasq's routine
cache_find_by_addr() to query dnsmasq's log for the host name.
Obviously, this has two major drawbacks: This code is kind of cumbersome
(esp. for IPv6) as I first have to format the IPs in the format that is
expected by this routine and secondly that does, of course, only work
for entries that are already in the cache. If a cache entry for is already present (since someone queried that manually),
then this works just fine. However, if nobody did that, then there will
also be no cache entry and there is no result.

My question is now: I would, of course, prefer to use the first version
( using gethostbyaddr() ) but that does not seem to work at all. I'm not
sure if it's maybe related to that a process cannot connect to its own
UDP socket or something, but I'd obviously prefer a rather simple
solution. Any suggestions are highly appreciated.

Best regards,

Dnsmasq-discuss mailing list

Reply via email to