Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Check IP Address of Subdomain

Tags:

subdomain

ip

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.

like image 956
Kevin_TA Avatar asked Nov 12 '12 16:11

Kevin_TA


2 Answers

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
like image 78
lacostenycoder Avatar answered Sep 20 '22 01:09

lacostenycoder


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

like image 27
Dewan Md Razib Avatar answered Sep 18 '22 01:09

Dewan Md Razib