How to get IP address of the browser

http://www.faqts.com/knowledge_base/view.phtml/aid/9005

How to get IP address of the browser when its operating behind a proxy/firewall? (applets...activex....??)
i have copied the code in my front page but it doesnt work. i dont have .asp setup.
Can u plz send me a simple javascript for .html page to do this job? just MAC address is required
Nov 23rd, 2006 22:39
Anzer M, Michael Scalise, Silvio Pedroso, Hari prasad, Qamar Ahmad, Built in ActiveX Problem in Windows XP

Hi,
there are some problems with below ActiveX it wont work in two builds of
Windows XP. Details are

The components used
<object classid="CLSID:76A64158-CB41-11D1-8B02-00600806D9B6"
id="locator" VIEWASTEXT></object>

<object classid="CLSID:75718C9A-F029-11d1-A1AC-00C04FB6C223"
id="theId"></object>

It works for all system except two. The specifications of the systems
are as follows:
IE version - 6
OS - Windows Xp Professional version
6.0.2900.2180.xpsp_sp2_rtm.040803-2158
and Windows Xp Professional version 6.0.2900.2180.xpsp_sp2_gdr.050301-1519

The systems are configured exactly like the others. It seems that
something is restricting the Active X control from loading into the page.

Please let me know if there is any work around or patch to this problem...

----End----

Hi,

You may use a client side javascript in order to discover the IP
address.

<script language="javascript">
alert(location.hostaddress);
</script>

(The solution above doesn't work. It retrieves only the public Ip
address, not the IPaddress on the PC behind the firewall/router. My
solution below does work, but it is a bit more complicated. Mike
Scalise 9/18/2003)

This solution does retrieve IP addresses from behind a firewall. It
does have limitations. The client computer must be running Windows. It
requires ActiveX to be enabled in the browser.
The first file uses Windows Management Instrumentation (WMI) to
retrieve the physical address of your network card (MAC Address) and
the IP address currently assigned to that computer. Remember, if client
computer gets an address using DHCP, this Ip address may change daily.
The MAC address never changes. It is burned into your network card and
is supposed to be unique in the world. (In fact, microsoft uses the MAC
address and the curent date and time to generate GUID's. )

The first page does an asyncronous call to the WMI system. When the
async call it is done, then it then automatically posts the data to
another file which displayed the results. Nifty cool.
Mike Scalise



Copy and paste the two ASPFiles below.

The first ASP file- NIC5.ASP

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>WMI Scripting HTML</title>

<script FOR="foo" EVENT="OnCompleted(hResult,
pErrorObject, pAsyncContext)" LANGUAGE="JScript">

document.forms[0].txtMACAddr.value=unescape(MACAddr);
document.forms[0].txtIPAddr.value=unescape(IPAddr);
document.forms[0].txtDNSName.value=unescape(sDNSName);
document.formbar.submit();
</script>
<script FOR="foo" EVENT="OnObjectReady(objObject,
objAsyncContext)" LANGUAGE="JScript">

if(objObject.IPEnabled != null && objObject.IPEnabled !
= "undefined" && objObject.IPEnabled == true)
{

if(objObject.MACAddress != null &&
objObject.MACAddress != "undefined")
MACAddr = objObject.MACAddress;


if(objObject.IPEnabled && objObject.IPAddress(0) !=
null && objObject.IPAddress(0) != "undefined")
IPAddr = objObject.IPAddress(0);

if(objObject.DNSHostName != null &&
objObject.DNSHostName != "undefined")
sDNSName = objObject.DNSHostName;

}
</script>

</head>
<body>
<p>


<FONT color="red"><span
ID="info"> </span>. </FONT>
<object classid="CLSID:76A64158-CB41-11D1-8B02-
00600806D9B6" id="locator" VIEWASTEXT>
</object>
<object classid="CLSID:75718C9A-F029-11d1-A1AC-
00C04FB6C223" id="foo">
</object>

<script LANGUAGE="JScript">

var service = locator.ConnectServer();
var MACAddr ;
var IPAddr ;
var DomainAddr;
var sDNSName;
service.Security_.ImpersonationLevel=3;
service.InstancesOfAsync
(foo, 'Win32_NetworkAdapterConfiguration');
</script>
</p>


<form method="POST" action="NICPost.asp" id="formfoo" name="formbar">

<input type="hidden" name="txtMACAddr">
<input type="hidden" name="txtIPAddr">
<input type="hidden" name="txtDNSName">

</form>


</body>
</html>

*************************
This is the second file. It is an ASP page, but you could change it to
plain HTML and use Java to retrieve the form field values, if you
wanted.

NICPost.asp

<HTML>
<HEAD>
</HEAD>
<BODY>
Network Interface Card Information Page
<BR>
<BR>
<BR>
You are at IP Address <STRONG>
<%=request.form("txtIPAddr")%>
</STRONG>
<BR>
Your MAC address on your network card is <STRONG>
<% =request.form("txtMACAddr")%>
</STRONG>
<BR>
Your DNS Host name is <STRONG>
<% =request.form("txtDNSName")%>
</STRONG>
<BR>
<BR>
<BR>
To confirm your IP and MAC address information, go to
the command prompt and
type in
<BR>
<BR>
IPCONFIG/ALL
<BR>
<BR>
ASP reports that your IP Address is <STRONG>
<%
response.Write Request.Servervariables("REMOTE_ADDR")
%>
</STRONG>which is your external WAN IP address that
anyone can see,
<BR>
but maybe be shared by hundreds of users if you use Net
Address Translation
(NAT)
<BR>
through a common router.
</BODY>
</HTML>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章