6

Is there any way to do a reverse lookup using python, to check the list of websites sharing the same IP address in a shared hosting?

Some web sites offer a tool for this purpose .

2
  • 2
    This is not possible with reverse DNS. You need a database that matches hostnames to IP addresses and then search by IP address. Reverse DNS searches in the PTR records. Most domains only have one, and it's not necessarily the hosted domain. Per example, one of google.com A record points to 74.125.228.97, but the reverse DNS entry for that IP is iad23s08-in-f1.1e100.net. Commented Nov 8, 2013 at 20:09
  • I think I should use python with an another API to do this . Commented Nov 8, 2013 at 20:14

1 Answer 1

14

DNSPython

Technically, you can use DNSPython to do a reverse lookup.

Pip install it

$ pip install dnspython 

Then do your reverse query:

>>> from dns import resolver >>> from dns import reversename >>> addr = reversename.from_address("74.125.227.114") >>> resolver.resolve(addr, "PTR")[0] <DNS IN PTR rdata: dfw06s16-in-f18.1e100.net.> 

socket.gethostbyaddr

You can also use socket.gethostbyaddr

>>> import socket >>> name, alias, addresslist = socket.gethostbyaddr('192.30.252.130') >>> name 'ip1c-lb3-prd.iad.github.com' 

Note that you'll want to check for a socket.herror Exception when using gethostbyaddr.

Problems with doing a reverse lookup

As for finding out what sites are hosted on a particular IP, this may not lend the best results in a shared hosting environment. It will likely tell you about the provider, not the site:

14:38:43 ~/code/tmp$ ping mozeyondown.com PING mozeyondown.com (173.203.99.161): 56 data bytes 64 bytes from 173.203.99.161: icmp_seq=0 ttl=56 time=40.924 ms 

Let's look up that address now

14:38:54 ~/code/tmp$ dig +noall +answer -x 173.203.99.161 161.99.203.173.in-addr.arpa. 86053 IN PTR 173-203-99-161.static.cloud-ips.com. 

Looking it up via Python

>>> import socket >>> name, alias, addresslist = socket.gethostbyaddr('173.203.99.161') >>> name '173-203-99-161.static.cloud-ips.com' 

Same goes for using DNSPython.

Sign up to request clarification or add additional context in comments.

1 Comment

I think asking for a tool to get a list of all domains hosted in 1 shared hosting IP: For exp something like bing: bing.com/search?q=IP:87.98.235.184 And/Or other paid services like : 1. yougetsignal tools web-sites-on-web-server 2. hackertarget reverse-ip-lookup

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.