Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Detecting visitor IP is easy. But how about detecting DNS server ips of a visitor ?

I found this PHP function, however it finds only domain names' DNS.

dns_get_record("website.com", DNS_ANY);

Is it possible to detect visitor DNS server ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
289 views
Welcome To Ask or Share your Answers For Others

1 Answer

It's not easy, but it can be done. There's a demonstration of the approach suggested in a separate answer by Adam Dobrawy at http://ipleak.net/

To add a bit of detail, the way you can implement something like this is:

Part 1 - Set up your own DNS server on myspecialdomain.com

This DNS server needs to be custom written to log and store the incoming request and the source IP address. This storage only needs to be for a short period of time, so something like memcache might work nicely. The DNS response should be an NXDOMAIN.

Part 2 - Your client-side code

In your Javscript make and store a large random number. Make the browser lookup .myspecialdomain.com. Load this via a JS img tag with an error handler. In that error handler, now make a query to your server side code passing the random number.

Part 3 - Your web application (server side)

You need to implement some server side logic that takes the random string, looks it up in the datastore, and retrieves the IP address of the DNS server. Note the IP address here will be the IP Unicast address of the particular server, it won't be an IP Anycast address like 8.8.8.8. Here you can use GeoIP or Whois databases to determine the owner of that IP address (OpenDNS, Google etc). You can then generate a response to send to the client logic.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...