{"id":49,"date":"2006-04-26T23:09:02","date_gmt":"2006-04-27T04:09:02","guid":{"rendered":"http:\/\/raffy.ch\/blog\/?p=49"},"modified":"2006-04-26T23:09:02","modified_gmt":"2006-04-27T04:09:02","slug":"command-line-dns-lookup","status":"publish","type":"post","link":"https:\/\/raffy.ch\/blog\/2006\/04\/26\/command-line-dns-lookup\/","title":{"rendered":"Command Line DNS Lookup"},"content":{"rendered":"<p>Something I ran into a couple of times this week is how to do an easy dns lookup on the command line:<\/p>\n<p><code>cat data | perl -M'Socket' -na -F\/,\/ -e '$dns=gethostbyaddr(inet_aton($F[0]),AF_INET)||$F[0]; print \"$dns,$F[1],$F[2]\\n\"'<\/code><\/p>\n<p>The code assumes that you have an IP address in the first column. It uses -F\/,\/ to split the input into arrays, does a DNS lookup on the first column and returns either the dns name or if that was not found, it returns the original IP address.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Something I ran into a couple of times this week is how to do an easy dns lookup on the command line: cat data | perl -M&#8217;Socket&#8217; -na -F\/,\/ -e &#8216;$dns=gethostbyaddr(inet_aton($F[0]),AF_INET)||$F[0]; print &#8220;$dns,$F[1],$F[2]\\n&#8221;&#8216; The code assumes that you have an IP address in the first column. It uses -F\/,\/ to split the input into arrays, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-49","post","type-post","status-publish","format-standard","hentry","category-unix-scripting"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/raffy.ch\/blog\/wp-json\/wp\/v2\/posts\/49","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/raffy.ch\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/raffy.ch\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/raffy.ch\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/raffy.ch\/blog\/wp-json\/wp\/v2\/comments?post=49"}],"version-history":[{"count":0,"href":"https:\/\/raffy.ch\/blog\/wp-json\/wp\/v2\/posts\/49\/revisions"}],"wp:attachment":[{"href":"https:\/\/raffy.ch\/blog\/wp-json\/wp\/v2\/media?parent=49"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/raffy.ch\/blog\/wp-json\/wp\/v2\/categories?post=49"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/raffy.ch\/blog\/wp-json\/wp\/v2\/tags?post=49"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}