user198989
user198989

Reputation: 4665

Is it possible to detect visitor DNS server?

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 ?

Upvotes: 9

Views: 7391

Answers (5)

Adam T
Adam T

Reputation: 164

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.

Upvotes: 11

Adam Dobrawy
Adam Dobrawy

Reputation: 1215

Yes, you can, like detecting page resolution of visitors.

You need own DNS server and force user to resolve unique dns name. If user tried to resolve it then they will leaks to your DNS server own DNS server address. Next to DNS server have to share information who asked about the unique dns name to your web apps.

Upvotes: 10

Xiaokun Zheng
Xiaokun Zheng

Reputation: 69

The answer is NO. All the server got is a TCP connection to the visitor, that is, an [IP, Port] pair. DNS resolution depends on visitor's local configuration and can be done by a proxy.

Upvotes: -1

Anthony Giorgio
Anthony Giorgio

Reputation: 1864

The DNS request happens first, as it is required to resolve the hostname to an IP address. Once this is complete, then a separate request is performed to the address in question.

Upvotes: -1

user188654
user188654

Reputation:

DNS resolution is not part of the request itself which means there is no way for the receiver of the request to know which DNS was used by the client (browser).

Upvotes: 3

Related Questions