Question

Get the IP Address ( Client MAC address ) by CGI Codes

Asked by: auae

Hii ...

i want to get IP Address for the PC ( Client MAC address ) by some CGI Code .... like this URL ..

>> http://checkip.dyndns.org

in this URL i can get my real IP Address for the PC ( Client MAC address ) ... but i want to get the code can make the same ...

and please any one will help me .. please give the FULL code... i mean .. i want to copy it and put it in my program to record the ( Client MAC address ) for the user in some logs which i can check it later !!

Note 1: is this Quistion will help me ( http://www.experts-exchange.com/Programming/Programming_Languages/Perl/Q_20850500.html ) ???

Note 2: I DONT want this one :
@gettheip = split(/\./,$ENV{'REMOTE_ADDR'});
$ip = "$gettheip[0].$gettheip[1].$gettheip[2]";
i already have it :) ...

Note 3:
see this picture : http://progxx.com/pcip.jpg
when you go to the  Command Prompt  ( Start >> Run >> CMD ) write (( ipconfig /all )) ... this what i want exactly !!

thanx alot
bye

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2004-06-11 at 04:20:20ID21022121
Tags

address

,

mac

,

get

,

ip

,

client

Topic

CGI Scripting

Participating Experts
4
Points
300
Comments
16

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. CGI
    What deferent cgi .pl and .exe how can we create a .exe cgi? thanks
  2. CGI
    i need a cgi that can save an URL output to a file! but this cgi must not using LWP libs or others lib! examples: input ot this cgi is http://www.geocities.com/cgi-bin/members?id=tulung and then the cgi save the html output from this url to a file. but this cgi must not usin...
  3. cgi
    How to connect database using cgi programs?
  4. CGI
    Will someone give me an example of a html form with email, name, and phone number, where you can scan them to make sure all the textboxes are full. Then submit them to another cgi script or email. No modules please thanks brent
  5. CGI
    Will someone give me an example of a html form with email, name, and phone number, where you can scan them to make sure all the textboxes are full. Then submit them to another cgi script or email. No modules please thanks brent
  6. CGI
    Will someone give me an example of a html form with email, name, and phone number, where you can scan them to make sure all the textboxes are full. Then submit them to another cgi script or email. No modules please thanks brent

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: bebonhamPosted on 2004-06-11 at 11:40:09ID: 11291388

MAC address and IP address are 2 different things.

http://checkip.dyndns.org

the above page checks your real public IP address, which is what you get from $ENV{REMOTE_ADDR} ...


http://www.experts-exchange.com/Programming/Programming_Languages/Perl/Q_20850500.html

the above question is about getting a MAC Address, which is like dd-dd-dd-dd-dd-dd in hex digits
If that is what you want to do, the question above contains the solution.


finally, in note 3, you again say you want the IP address, which you get from $ENV{REMOTE_ADDR}

if you have any furthur questions, or would like a sample script showing how to get either the MAC address or IP address, I can help you with those.

bebonham

 

by: auaePosted on 2004-06-11 at 13:25:42ID: 11292375

thanks Dear ( bebonham ) ...

for telling me this ( MAC address and IP address are 2 different things. ) ... i thought that the tow are same ..

so could you please tell me HOW to get the two things !!

The Public IP like in Note ( 3 ) ....

and the Mac IP ....

but please i want them by CGI ONLY if you can ....
---------

for this (( http://www.experts-exchange.com/Programming/Programming_Languages/Perl/Q_20850500.html  )) .. i test it ... and c this :
http://arabszone.com/htm.htm .... you will see Security Error for JAVA ... so it wont help me !!! :(( ... it will just if we skip that ( ActiveX Control ) !!!

--------------

Thanks alot for your time ...

bye

 

by: x4hPosted on 2004-06-11 at 14:49:17ID: 11292907

To get the IP address (example):

#!/usr/bin/perl

use warnings;
use strict;

use CGI qw/:standard/;

my $remote_ip = $ENV{'REMOTE_ADDR'};

print header;
print "Your IP is: $remote_ip\n";

-------------------------

As for the MAC address the only way im aware of getting it is via active x, there is no perl/php etc command for returning it as you need something to execute system site to get the address.

 

by: bebonhamPosted on 2004-06-11 at 15:00:20ID: 11292964

as you already know, the client's public ip address is in $ENV{REMOTE_ADDR}";

I am sorry I can't help you more with a solution to find a remote MAC address, while doing research, I read the opinion, that the MAC address from the client usually never reaches a server, because only the most recent MAC address is sent from point to point (nearest upstream).  Now I think I believe that this is true, although at the same time, obviously there are ways using an application such as activex, exe, or applet to send you the MAC address...this is not what you want.

I believe that without doing this, it is not possible.  Although in my research I found some examples of "asp.net" that said they worked, they would not even compile without iis installed (which I don't have), and I kind of doubt weather they would work for any machine behind a router (many high speed connections are now)

However, if you can get them to run a script or executable on their machine, then it can be done.

for what it is worth, here is how to get your mac address in perl on a windows box... on linux I think you use ifconfig -a instead of ipconfig/all

bebonham

 

by: bebonhamPosted on 2004-06-11 at 15:01:10ID: 11292968

system('ipconfig /all > temp.ipc');

open TEMP, "temp.ipc";

while(<TEMP>)
{
if(substr($_,0,10) =~ /Physical/)
{
print $_;
}
}
close TEMP;
system('del temp.ipc');

 

by: auaePosted on 2004-06-12 at 08:01:14ID: 11295813

Dear " x4h " ....

first of all .. thanks alot for your time ....
about the example you put it for me .... the result is : Your IP is: 213.42.2.25 ,
and you can check it out by this link : http://arabszone.com/cgi-bin/mm.cgi

but it is totaly derfrent when i check it by this site http://checkip.dyndns.org , and by the ( ipconfig /all ) ,
it was : Current IP Address: 217.164.254.124

So what i want to know now HOW to GET the IP in the http://checkip.dyndns.org  ????

----------
Dear "  bebonham " .... i am realy feel shy from you ... Thanks you alot for the time ....

let me back to the problem ... my dear ... i want to know .. How this code will help me ... !!
system('ipconfig /all > temp.ipc');

open TEMP, "temp.ipc";

while(<TEMP>)
{
if(substr($_,0,10) =~ /Physical/)
{
print $_;
}
}
close TEMP;
system('del temp.ipc');

it will get me the same result of http://checkip.dyndns.org  !!!

..... I feel i won't find the answer .. becouse my quistion is very stupid :(((

Thanks all
bye

 

by: x4hPosted on 2004-06-12 at 11:53:46ID: 11296633

REMOTE_ADDR will return the address of the host requesting the page off the server. Where your IP may differ is if for some reason you not connecting directly to the page, rather going through a proxy or the page is being loaded from your ISP's cache.

I checked both pages and for me both pages showed me to have the same IP.

www.whatismyip.com is also another source for checking your IP.

 

by: bebonhamPosted on 2004-06-12 at 12:34:56ID: 11296761

I aggree with x4h's assesment of why you are getting 2 different IP addresses...

try searching in google "What is my ip address"  and the search result will come up with the ip address of google's search engine.  but when you click on the link it will show your ip, unless you are behind a proxy.

auae: The script I sent you was to get mac address on the local windows computer.  something like that would need to be done on the client computer inorder to get mac address with perl.  Obviously perl isn't the best choice for a client side program unless you are compiling it.  

I think that there is really no solution to get the mac address without a program running on the client computer, and since you don't want to use activex (and therefore, I assume you don't want to use any programs that the client needs to download), I think your best bet would be to try an alternate strategy.

If you like, you could explain why you need the MAC address, and perhpas someone could come up with a good alternative...like perhpas cookies could work for you?

good luck, and your question is not stupid...it's just hard.

bebonham

 

by: ahoffmannPosted on 2004-06-14 at 09:28:31ID: 11307990

the only value you can get is $ENV{'REMOTE_ADDR'}
Dot.
This IP is either the public IP of the client, or the public IP of an proxy inbetween.

To get anything else from the client you need active scripting (which is hopefully disabled by everyone using the internet), mean JavaScript, Active X or any kind of applet which then sends back the required information to your server. I'd call such a functinality spyware or more general: malware, hence never enable scripting ;-)
No other possibilities. Dot.

 

by: TintinPosted on 2004-06-14 at 14:48:09ID: 11310876

Let's go back a few steps and ask exactly *why* you want the IP address?  What are you going to use it for?

 

by: auaePosted on 2004-06-15 at 04:14:30ID: 11314073

Dear Mr. "x4h" ... Thanks alot .... i think the change of ip between the code that you gave me and http://checkip.dyndns.org
that because my Internet providedor Service has a proxy blah blah blah ... and more security ( as they said to us )

Dear Mr. "bebonham" ... thank you also ... for the time you gave me :) ..

Dear Mr. "ahoffmann" .. thanks you dear ... but dear ... i think it is different either the public IP of the client, or the public IP of an proxy inbetween (( see above ))
===================================================
first of all .. thanks alot for your time ....
about the example you put it for me .... the result is : Your IP is: 213.42.2.25 ,
and you can check it out by this link : http://arabszone.com/cgi-bin/mm.cgi

but it is totaly derfrent when i check it by this site http://checkip.dyndns.org , and by the ( ipconfig /all ) ,
it was : Current IP Address: 217.164.254.124
===================================================

Dear Mr. "Tintin" .. Thanks alot ... i want it to record the IP for the user will enter to my new program in CGI ... thats it !! :) ..

--------------------

any way .... Thanks alot dear .. i found what i want by this code :

#!/usr/bin/perl

use warnings;
use strict;

use CGI qw/:standard/;

my $remote_ip = $ENV{'REMOTE_ADDR'};
my $remote_ip2 = $ENV{'HTTP_X_FORWARDED_FOR'};

if ($remote_ip2 eq "" ) {
      $remote_ip2 = "Unkown";
}

print header;
print "Your IP is: $remote_ip\n<br> Your Real IP is: $remote_ip2";

----
so i found it in this code (( 'HTTP_X_FORWARDED_FOR' )) ....

Thanks alot all ..

bye

 

by: auaePosted on 2004-06-15 at 04:16:37ID: 11314092

and to check that code .. see this web page :
http://arabszone.com/cgi-bin/mmmm.cgi

 

by: x4hPosted on 2004-06-15 at 04:41:52ID: 11314214

'HTTP_X_FORWARDED_FOR' will ONLY show you the real IP if the proxy is setup to do so. If the proxy is an anonymous proxy then the proxy will either out its IP for both the remote_addr and http_x_forwarded_for or not send it out at all.

If your only logging hits then this isn't a problem, I just thought I would make you aware :)

 

by: ahoffmannPosted on 2004-06-15 at 05:50:48ID: 11314704

auae, please read x4h's last comment, then reread my comment:
  ==> there is no reliable way of getting the clients IP except when using malware (which needs to be allowed by the client, somehow). Dot.

 

by: x4hPosted on 2004-06-15 at 06:22:23ID: 11314906

ahoffmann, not really true. If you look up what malware is:

"Short for malicious software, software designed specifically to damage or disrupt a system, such as a virus or a Trojan horse." (source: http://sbc.webopedia.com/TERM/M/malware.html)

You will see that malware is designed to disrupt / damage a system. Getting the MAC address from a system does neither of these and there are a number of useful applications of having a the MAC address, such as allowing a higher level of security.

Dot ;)

 

by: ahoffmannPosted on 2004-06-15 at 07:47:51ID: 11315792

x4h, that's just *one* definition of malware, mine is like:
  anything that harms my system, my privacy, my reputation, my property, or anything else I don't like
;-)
ask a spammer, and you'll get a completely different definition :-((

sorry for being off-topic

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...