Ok I am looking into see if it is possible to get the DNS of a computer using PHP. I am aware that PHP allows for getting DNS info for a website or server but can it be done to cross reference a computers DNS somehow using $_SERVER['REMOTE_ADDR'] and other PHP functions.
Asked
Active
Viewed 2,517 times
-2
-
2You mean get the IP address of the machine the script is running on? The local machine's hostname? – Marc B May 05 '12 at 00:20
-
I need to somehow get the DNS setting from the users computer not the server. – Justin P Greer May 05 '12 at 00:25
-
1what dns setting? You want to know which dns servers the user is using to resolve lookups? Or do you mean the hostname of the machine the user is on? Whatever you're getting at, it's not "dns setting". – Marc B May 05 '12 at 00:26
-
I have a project where I have to check if a users computer is infected by the DNSchanger Trojan. I have the IP of the black listed servers but I have to see if a user when visiting my site has been infected by the trojan. So I guess it would be seeing what DNS they are using to resolve lookups.. – Justin P Greer May 05 '12 at 00:32
-
1No, you can't determine that remotely. That sort of information is not transmitted on a standard HTTP request. You could get around with an ActiveX control or a high-privilege Java applet, probably, but there's nothing you can do to figure this out automatically WITHOUT non-standard means. – Marc B May 05 '12 at 00:33
-
It can be done. They are doing it here but I have no idea how [link](http://www.dns-ok.us/) – Justin P Greer May 05 '12 at 00:38
-
3@MarcB: That's not entirely true; AIUI, DNSChanger changes a computer's resolvers to servers that have for some time been operated by law enforcement agencies. Assuming that those resolvers don't perform their lookups via other forwarders, one could configure a split DNS horizon that responds to those resolvers with a different address for one's hostname versus queries from elsewhere, and then assume that visitors arriving at that address are probably infected; better yet, if one has control over the user's Internet connection, one could intercept DNS queries to such servers... – eggyal May 05 '12 at 02:04
-
@eggyal: true enough, but that's still not detecting a user's "dns settings" as the OP wants, e.g. the IPs of the user's DNS servers. – Marc B May 05 '12 at 02:14
-
Might not be able to detect the users setting but base on @eggyal it is possible to look for characteristics of the settings being in use. They are performing these checks online over the internet with every browser and I am curious how they are detecting the settings. – Justin P Greer May 05 '12 at 14:17
-
Its a shame that not one person could help and and it is being done by the feds right now. – Justin P Greer Jun 07 '12 at 13:41
2 Answers
1
"" Is it possible to display the DNS of a computer using PHP ? ""
First of all i dont believe that you search, if your client IP has an DOMAIN NAME assign to it, if so, the answer above, or some shell commands like 'whois' can help you.
What i believe, is that you try to figure out 'DOMAIN NAME SERVER', of your client. To do this you need to run some commands, or scripts, in the client machine.
PHP, is a server-side script langage. You must create a page contain, java, javascript, and of course, to have the permissions you need, to do what you think you can do.

kapad
- 52
- 7
0
You can use gethostbyaddr
for this:
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
However, I must warn you that $_SERVER['REMOTE_ADDR']
can have a few forms; here are a few articles that talk about this value: