Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

How to get client machine IP address

by Jeganath KS (Novice)
on Aug 24, 2010 at 10:14 UTC ( #856897=perlquestion: print w/ replies, xml ) Need Help??
Jeganath KS has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, I need to develop a Perl script which should run on server machine to find out the requested client's IP address and the type of request(Actually I need to track what are all the web pages that are being requested by particular client machine). Is it possible with Perl? If yes, how do I get started?

Comment on How to get client machine IP address
Re: How to get client machine IP address
by JavaFan (Canon) on Aug 24, 2010 at 10:27 UTC
    The simplest way would be to just run an analyzer on the web server logs. There are many (free) analyzers out there. Just do a search.

    Bear in mind though that all you'll be getting is whatever IP address the last proxy in the request chain was using at the time. IP addresses do not identify machines. IP addresses are assigned to interfaces. One machine may have multiple interfaces (even the simplest setup will typically have at least two interfaces: 127.0.0.1 for the loopback interface is also an IP address). One interface may have multiple IP addresses. And IP addresses may move.

      I have 20 machines connected through LAN with a single gateway. I need to track/log those 20 machines activity from the gateway machine(I just need to log what are all the websites requested, and from which machine that website was requested). Can I do it with Perl script. If yes, can you please guide me.

Re: How to get client machine IP address
by doug (Pilgrim) on Aug 24, 2010 at 17:01 UTC

    What is the server serving? Someone else assumed it was a web server, but I don't see that in your request. This does matter. If you can hack up the source for the server, then the easiest command is  getpeername() . If not, you'll have to go through some secondary thing like scanning log files or running  netstat .

    - doug

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://856897]
Approved by moritz
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2014-10-01 10:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (3 votes), past polls