Linux Kernel Module program to obtain domain name from IP

Kristof Provost kristof at sigsegv.be
Tue Jul 8 09:07:05 EDT 2014


On 2014-07-08 20:19:09 (+0800), shhuiw <shhuiw at 163.com> wrote:
> DNS loopkup should use UDP packet, and you have to construct UDP request
> based on your captured IP addresses in your module.
DNS can actually use both TCP and UDP.

> And you have to use DNS server fallback lists and time-out control if some DNS
> server cannot work well.

Yeah. Doing DNS lookups (forward or reverse) is complicated. 
There's a dns_query function in the kernel (net/dns_resolver), which
apparently upcalls into user space, but I'd avoid dealing with DNS in
the kernel at all.

Just pass the IP address to user space and let it deal with it. There
are plenty of DNS libraries available. Odds are you need to pass the
resulting information to user space anyway, so you're not really losing
anything.

What are you trying to accomplish anyway?

Regards,
Kristof



More information about the Kernelnewbies mailing list