How to Check IP Address of Subdomain
ip, subdomain
Solution
You should be able to just use nslookup from a terminal
nslookup google.com
nslookup mail.google.com
From here it's trivial to write a script for this. Here is a simple ruby example:
nslookup.rb
#!/usr/bin/env ruby
domain = ARGV[0]
lookup = `nslookup #{domain}`.split("\n")
lines = lookup.select{ |line| line[/Address/] }[1..-1]
ips = lines.map{ |l| l.split('Address: ').last }
verb = ips.count > 1 ? 'are' : 'is'
puts "the IP addresses for #{domain} #{verb}:\n#{ips.join("\n")}"
Run from command line
ruby nslookup.rb api.stackoverflow.com
# or just
./nslookup.rb api.stackoverflow.com
should output something like
the IP addresses for stackoverflow.com are:
151.101.193.69
151.101.65.69
151.101.1.69
151.101.129.69
Problem
I'm sending XML from a client's site to an external server. This external server admin needs to verify the IP from the sender. We have the script working fine when sending from the main site (domain.com), but I am not sure when we are sending from a subdomain of the main site (sub.domain.com, getting an error currently). Is there a way to check the IP of a subdomain so I can give the admin the right IP address? Thanks. UPDATE: I've used the firefox extension 'IP Addresses and Domain Information' and am comparing the info from both domain.com and sub.domain.com and both look pretty much identical.