Sep 222009
 

There are many ways, scripting/language to obtain remote IP address of the user who is browsing our website.

PERL

#!/usr/bin/perl
use CGI;
print "Content-type: text/plain; charset=iso-8859-1\n\n";
my $q = new CGI;
print "<b>Your Remote IP Address :" . $q->remote_host() . "</b>";

PHP

<?php
echo "<b>Your Remote IP Address :" . $_SERVER['REMOTE_ADDR'] . "</b>";
?>

C

#include <stdio.h>
#include <stdlib.h>

void PrintHeader(void)
{
        printf("Content-Type: text/html\r\n");
        printf("\r\n");
}

void PrintRemoteAddress(void)
{
        printf("<b>Your Remote IP Address: %s</b>\n"
                        ,getenv("REMOTE_ADDR"));
}

int main(void)
{
        PrintHeader();
        printf("<html><body>");

        PrintRemoteAddress();

        printf("</body></html>");
        return 0;
}

PYTHON

#!/usr/bin/python

import os

print "Content-type: text/html\r\n\r\n";
print "<b>Your Remote IP Address: %s" % os.environ['REMOTE_ADDR'] + "</b>";

And more…

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.