问题
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.
回答1:
I was also search on this topic then i have found a web site that helps me to find my subdomains IP address http://www.hcidata.info/host2ip.htm
回答2:
You should be able to just use nslookup from 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 }
if ips.count > 1
puts "the addresses for #{domain} are:\n"
else
puts "the address for #{domain} is:\n"
end
puts ips
Run from command line
ruby nslookup.rb api.stackoverflow.com
# or just
./nslookup.rb api.stackoverflow.com
should output something like
the address for api.stackoverflow.com is:
198.252.206.16
来源:https://stackoverflow.com/questions/13347650/how-to-check-ip-address-of-subdomain