Last active
August 29, 2015 13:56
-
-
Save yuya-takeyama/8911897 to your computer and use it in GitHub Desktop.
引数に指定した IP を逆引きして、その結果をさらに正引きするヤツ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# 引数に指定した IP を逆引きして、その結果をさらに正引きするヤツ | |
# https://gist.github.com/yuya-takeyama/8911897 | |
# Author: Yuya Takeyama | |
unless ARGV[0] | |
puts "Usage: " | |
puts '$ ' + File.basename(__FILE__) + " HOST" | |
exit 255 | |
end | |
host = ARGV[0] | |
ptrs = `dig +short -x #{host}`.split("\n") | |
if ptrs.size == 0 | |
puts "No PTR record is set!" | |
exit 1 | |
end | |
ptrs.each_with_index do |ptr, i| | |
puts "PTR[#{(i + 1).to_s}]: #{ptr}" | |
print " -> " | |
rehost = `dig +short #{ptr}` | |
puts rehost == "" ? "NOT FOUND" : rehost | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment