PDA

View Full Version : Logging IP and /or MAC addresses of site visitors . . .


desktopjockey
11-28-2002, 06:40 AM
Greetings again,

I know some sites, especially secure ones, have the ability to capture and log the ip addresses and MAC addresses of visitors. how do they do that? Is there a utility or some code I could add to a site page that will allow me to collect the data?:bang:

I'm having some vandalism at my site and need to log who is doing this. Thanks for all your assistance.

cbkihong
11-28-2002, 04:45 PM
To log people's IP address is easy. If you know a server-side scripting language like Perl or PHP, the REMOTE_ADDR environment variable can be read to get the remote party's IP address.

e.g. a Perl CGI script may contain this code to achieve this:

open ERRLOG, ">>", "logfile.txt";
$ipaddr = $ENV{'REMOTE_ADDR'};
print ERRLOG "[$ipaddr]\n";

to save it to logfile.txt.

But I think there are some existing CGI/PHP scripts that can do this dirty work for you. Go to http://php.resourceindex.com and http://www.cgi-resources.com and you should find some that does this for you.

As for MAC address, I think you have obtained some incorrect information or misunderstood something. An MAC address is used for link-level transmission. i.e. between the two ends of a direct link. On any given machine, you can only obtain the MAC address of any machines directly connected to you (using ARP). Considering a visitor is highly unlikely to be connected to your machine through a direct link, you will see the MAC address of the router that forwards the request to you, instead of the sender's. This is basic networking concepts. That's why I think you should have misunderstood something. Unless the sender artificially tries to embed his/her MAC address in the packet, you should not be able to know it.

Therefore, MAC addresses have only very limited use on the Internet scale. IP is the only hope you may have.

desktopjockey
11-28-2002, 06:08 PM
You're right about the MAC address. I've been spending too much time in our wiring closets. Another "cranial oderiferous fumingous" (apologies for any offenses) on my part. I'll research the SSI sugestion and the links offered.

All the best . . .