Reverse DNS problem

Hi everyone,

I am having a problem in the following area:

I want to arrange list of Ip Addresses selected from a multiple files and make it look like this:

"IP=192.168.0.1, hostname=snake.cooliris.com"

Now i have already written the code to select the ip address from various files but want this part to be working.

Thanks a lot.

And where is your code and where is the problem?
Whitout the code we can't tell you where the problem is!

Hey ,
my logic was to get as many file sin as possible so here is the half part of the code

Please correct me if i am wrong.

grep '^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}$' followed by respective file names which lies under /var/lib/output/ for me atleast.

Now i want to write the code for reverse dns here .....am i on the right path?

I just wanted to add that i know the commands for reverse dns is Nslookup or dig -x followed by the ip address but the thing how do i make to take the ip address from various files and format it.

Your regexp will match anything upto 999.999.999.999

For IPv4 try this awk solution:

awk -F'.' 'NF==4 && $1 > 0 && $1 && $2 && $3 && $4 <256'

If IP match use the system function to dig your ip and printf to format the output.

Regards,


  1. 0-9 ↩︎

Hey thanks for the reply but i am not aware how to use the system function to dig my ip from the previous result.....can you enlighten me on that part cause i am having a tough time figuring out how to make the function grab the ip from the grep expression and give it to the reverse dns process.