use CGI qw(:standard);
print header,
start_html( 'Your IP address'),
h1( 'Your IP address'),
p( strong( $ENV{REMOTE_ADDR} )), end_html;
Main Topics
Browse All TopicsHi...
Just need a quick perl script, that once executed (in the browser),
it simply prints my computer's IP address on the screen.
That's all. I used to have this code, but it is now lost or buried inside my computer ;)
So i thought to ask...
Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
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.
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.
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.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
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.
OKSD & jmcg both codes ARE waorking...
BUT:
1) they are displaying diffrent IP address!!!
2) Both IPs are not what i see as the "clinet IP address"
what to do?
for example there is a JS code.. That works ONLY in netscape..
it display a totally diffrent IP address (in the netscape browser)...
<script language="JavaScript">
<!--
function namosw_infotext()
{
var username;
var type, i, top, obj;
for (i = 1, top = 0; i < namosw_infotext.arguments.
obj = eval('document.'+namosw_in
if (obj == null) continue;
type = namosw_infotext.arguments[
if (type == 'username') {
if (username == null)
username = prompt(namosw_infotext.arg
username = (username == null) ? '' : username;
obj.value = username;
} else if (type == 'moddate') {
obj.value = document.lastModified;
} else if (type == 'ipaddr' || type == 'hostname') {
if (navigator.appName == 'Netscape') {
var host = java.net.InetAddress.getLo
obj.value = (type == 'ipaddr') ? host.getHostAddress() : host.getHostName();
} else {
obj.value = '';
}
}
}
}
// -->
</script>
then in the <body>
OnLoad="namosw_infotext(''
again ..this works ONLY with netscape...
i need somthing that works with all browsers, that's why i asked for a perl script.
Maybe we should take a step back. What are you really trying to do?
At your PC, you have several resources available for discovering your IP address. Making a round trip to a web server to display it seems a bit silly.
By the time a request gets to a CGI script running on the web server, REMOTE_ADDR has been filled in by the web server with the address at the other end of the socket (the peer address) on which the request arrived. That's the address the response has to be sent to. It could be the address of a proxy or firewall and not the IP address assigned to your PC.
Of the three or more methods you've tried, which one gives you the IP address you _want_?
jmcg
..
I just want one of my friedns to forward his IP addres
to me whenever we chat...
he is a beginner, so it might not be easy to use
an inside resource to know the IP...
I thought that it would be easier to access a web
page and that's it.
I didn't understand what do you mean by
"It could be the address of a proxy or firewall and not the IP address assigned to your PC."
If so... then why i see the address when i log into some websites or try to make an order online?
it shows the clinet IP address..
>Of the three or more methods you've tried, which one gives you the IP address you _want_?
I need the one that i see when i click the "Dial-up Connection Status" window... there is a "clinet IP address"..
that's the one.
I couldn't agree more with jmcg, let's first define which IP address you really want to resolve... Locally, there are many ways of resolving (maybe resolving isn't appropriate expression) IP address. (Windows 2000, NT 4.0, 98 SE, 98 - "ipconfig" command, *NIX - "ifconfig"...). You must make clear which IP address you want to resolve, your local, your server assigned if on RAS connection, etc.
If your friend is using any version of Windows ("any") :-), you can make a simple batch script:
@echo off
ipconfig
echo.
pause
You'll get this if using Windows 2000 (very similar on other versions)...
Windows 2000 IP Configuration
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . : amfilip
IP Address. . . . . . . . . . . . : 192.168.1.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.254
Press any key to continue . . .
the line IP Address is the thing you want (this example is for my Ethernet adapter, but if you have more devices ie. modem it'll show the IP Address assigned to it).
Some people who use the Internet are on private networks. When they go to a web page, the IP address that is reported to the server will not be the IP address assigned to their PC; it will be an IP address of a firewall or proxy server.
If your friend is on dialup, chances are he is not firewalled or proxied (but it's possible he is). The REMOTE_ADDR reported by a web server ought to be reliable. There are quite a few sites that report back to you what your IP address is. One is at
http://www.broadbandreport
Or you could arrange for one of the scripts we gave you to be accessible to your friend.
But for your friend's situation, I recommend you get something extremely easy to use. I found this little utility at download.com:
http://download.com.com/30
It's freeware but I confess I don't know if it has bad habits or is otherwise unsuitable. You could look for others at www.download.com as well.
Business Accounts
Answer for Membership
by: OKSDPosted on 2003-05-06 at 14:16:43ID: 8474906
print "Content-type: text/html\n\n";
print "$ENV{'REMOTE_ADDR'}";
I think thats it... you'll need to add the shebang line (#!/usr/bin/perl) depending on your PERL path though.
Also, REMOTE_ADDR gives one IP, there is another that I havn't been able to get at with PERL, but REMOTE_ADDR is the most commonly used.
OKSD