Jump to content

Getting User's IP


sooty2006

Recommended Posts

hi,i am trying to get a users Real IP Address!i have tryed using but it shows the ISP Address!!

$ip=$_SERVER['REMOTE_ADDR'];

i have tryed using 2 scripts an a few more they are below

<?if (getenv("HTTP_CLIENT_IP")) $ip = getenv("HTTP_CLIENT_IP");else if(getenv("HTTP_X_FORWARDED_FOR")) $ip = getenv("HTTP_X_FORWARDED_FOR");else if(getenv("REMOTE_ADDR")) $ip = getenv("REMOTE_ADDR");else $ip = "UNKNOWN";echo "($ip)";?>

and ...

<?php$user_ip = $_SERVER['REMOTE_ADDR'];if (trim($user_ip) == '') { $user_ip = $_SERVER['HTTP_CLIENT_IP']; }if (trim($user_ip) == '') { $user_ip = $_SERVER['HTTP_X_FORWARDED_FOR']; }echo "($user_ip)";?>

but for some reason it always returns the users ISP Address which changes so often i need a permenant block to stop mebers gaining access to my site after they have been blocked!any answers will be greatly recievedthanks scott,

Link to comment
Share on other sites

In short: you can't.There are countless ways a user can present himself with a different IP adress, and if their ISP gives them IPs with a DHCP server, i.e. dynamic IPs, then they don't need to "hack" their way - the ISP will do it for them.There are MAC adresses which can identify a network card regardless of the IP, but they can be changed by the user too. Not to mention PHP doesn't provide a way for you to view them, as they are only preserved in the local are scope (until the user reaches the gateway of their ISP).There are also SSIDs which can identify a motherboard regardless of the IP or MAC of a network card, but they too can be changed and are preserved only in the local area scope.Bottom line: you can't ban users based on their adress, or anything else they provide for that matter.

Link to comment
Share on other sites

ok so is there anyway a user can be blocked permenently using anything?!!is Javascript not an option?is it simple to change your own MAC Address?!!if not i could use the mac address to block them from viewing my site! only people with a great deal of computer knowledge wud just b able to change thier MAC Address which means atleast i can block more than half of them!!

Link to comment
Share on other sites

ok so is there anyway a user can be blocked permenently using anything?!!
Well, using a hammer, you can go and break their computer... or their heads. That's the "manual" way. There's no automatic one.
is Javascript not an option?
No, as JavaScript doesn't have access to sencetive information like a MAC adress. I don't think it even has knowledge of the IP adress actually.
is it simple to change your own MAC Address?!!if not i could use the mac address to block them from viewing my site! only people with a great deal of computer knowledge wud just b able to change thier MAC Address which means atleast i can block more than half of them!!
For me, it's very easy. For most people it's not. And they would pretty much never change their MAC anyway, as ISPs (at least where I live) lock IPs by checking the MACs. This is to prevent (or at least reduce) IP theft. If anyone is to steal your IP while your computer is off (so it doesn't trigger "IP conflict" message) they must also know your MAC adress, and a Firewall can prevent your computer from telling any computer (other than the gateway) what your MAC is. It's pretty much the same deal with SSIDs, but they are harder to change (and I don't know if any firewall has an option not to disclose the SSID). Windows itself offers you the ability to change a MAC adress, but I only know of one program that can change an SSID.The problem from your perspective though is that you just don't have access to users' MAC adress or SSID. As I said, they are both visible only in the local scope. Unless the computers you're trying to block are from your own subnet, then you can't possibly see their MAC and ban them based on it.In other words, if your computer (I mean "server") has the IP 192.168.0.100 and the gateway is 192.168.0.1, then you could only possibly see the MACs for IPs from 192.168.0.1 to 192.168.0.254 (your server included of course). And even in that scenario, I don't know if PHP offers any way for you to see a MAC adress. If you're knowledgeable enough in C, you might write such an extension yourself, but again - it will only work in the local area network scope. Globally, there's no way.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...