<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div>Hi,<br><br>I think you need refer to some open source DNS client utilities, e.g <a _src="http://en.wikipedia.org/wiki/Nslookup." href="http://en.wikipedia.org/wiki/Nslookup.">http://en.wikipedia.org/wiki/Nslookup.</a><br><br>- shhuiw<br>&nbsp;<br></div><div id="divNeteaseMailCard"></div><br>At 2014-07-08 06:26:23, "Hettiarachchige Hasitha Shan" &lt;hh_shan@live.com&gt; wrote:<br> <blockquote id="isReplyContent" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">

<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style>
<div dir="ltr">I have a requirement to obtain the domain name from the destination IP from an outgoing packet. I am successful in capturing and obtaining the destination IP&nbsp; packets using the `netfilter` hook as shown below. <br><br>&nbsp;&nbsp; &nbsp;unsigned int hook_func_out(unsigned int hooknum, struct sk_buff * skb, const struct net_device *in, const struct net_device *out, int (*okfn)(struct sk_buff*)) <br>&nbsp;&nbsp; &nbsp;{<br>&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;ofs = 20;&nbsp;&nbsp; &nbsp;// Set theoffset to skip over the IP header.<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct iphdr *ip_header = (struct iphdr *)skb_network_header(skb);&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct udphdr *udp_header;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct tcphdr * tcp_header;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//Ican obtain the destination IP address of the packet <br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//like this<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;unsigned int dest_ip = (unsigned int)ip_header-&gt;daddr;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//or like this&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;char pkt_tbuf[16];&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;snprintf(pkt_tbuf, 16, "%pI4", &amp;ip_header-&gt;daddr);<br><br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//here I need to obtain the domain name of the obtained destination address<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br>&nbsp;&nbsp; &nbsp;}<br><br>However, I have no idea on how to use that IP to obtain the domain name of the obtained IP. <br><br>I tried many sources (https://www.google.com/search?client=ubuntu&amp;channel=fs&amp;q=linux+kernel+programming+domain+name+from+IP+&amp;ie=utf-8&amp;oe=utf-8) but did find any related information on the subject and will be really grateful if you experts would provide any sample code/ references to perform this task :) <br><br>Thank you very much :)<br>                                               </div>
</blockquote></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>