lookup reverse ip
By Mihamina Rakotomandimby on Friday 20 May 2011, 12:03 - linux - Permalink
Reverse IP
Reverse lookup is needed for several uses. To check what is the reverse of an IP address, one can issue:
dig -t PTR +short 99.123.204.41.in-addr.arpa.
Easily reverse an IP
Using "awk", reversing an IP address can be done with
$ echo "41.204.123.99" | awk -F "." '{for (i=NF;i>=1;i--) printf $i"."; print "in-addr.arpa."}'
Or putting this in a simple SHELL script (i.e "flip-ip.sh"):
#!/bin/bash
echo $1 | awk -F "." '{for (i=NF;i>=1;i--) printf $i"."; print "in-addr.arpa."}'
and calling it:
$ ./flip-ip.sh 41.204.123.99
Used in one line with "dig":
$ dig -t PTR +short $(flip-ip.sh 41.204.123.99)