Click here to register.
      
Bazaar


     Discuss > WebGUI Dev

IPs of interfaces apache binds to

User bernd
Date 7/6/2008 3:50 am
Views 908
Rating 0    Rate [
|
]
Previous · Next
User Message
bernd

How can I query IPs of interfaces apache binds to? I need this to distinguish between internal and external requests in the userSession table.


Bernd

--
Trying to build a non-profit community portal for free-climbers around Magdeburg/Germany. Check out http://www.klettern-md.de (under construction).



Back to Top
Rate [
|
]
 
 
knowmad

How can I query IPs of interfaces apache binds to? I need this to distinguish between internal and external requests in the userSession table.


Hi Bernd,

Can you explain more about what you're trying to do? Are you trying to find this info from a macro? a custom wobject? Generally, you can query the referer string to find where the request is coming from. For mod_perl, try $r->headers_in('Referer') (see perl.apache.org for more, code not tested).

I'm not sure how you're going to know if the request is internal or external without some kind of lookup table or a regex (depending on how big your internal network is).

 

William

----
Knowmad Technologies
http://www.knowmad.com



Back to Top
Rate [
|
]
 
 
bernd


Hi Bernd,

Can you explain more about what you're trying to do? Are you trying to find this info from a macro? a custom wobject?

Hi William,

I am trying to improve the UsersOnline macro. In one place, the number of visitors is determined by the following query:

SELECT COUNT(DISTINCT lastIp) FROM userSession where (lastPageView >= $epoch) and (userId = 1)

However, I noticed that the number of visitors is increased artificially by internal requests. I assume this is due to mod_proxy accessing mod_perl or maybe due to spectre. Anyway, I would like to filter out ips belonging to the loopback device and ips apache binds to. That should solve the problem. Any idea?

Bernd

--
Trying to build a non-profit community portal for free-climbers around Magdeburg/Germany. Check out http://www.klettern-md.de (under construction).



Back to Top
Rate [
|
]
 
 
JT
Are you saying that you don't already know what your internal IP  
ranges are?

$session->server gives you a reference to Apache2::ServerUtil, which  
can probably give you those IPs.

> How can I query IPs of interfaces apache binds to? I need this to  
> distinguish between internal and external requests in the  
> userSession table.
>




JT Smith
ph: 703-286-2525 x810
fx: 312-264-5382

Create like a god. Command like a king. Work like a slave.



Back to Top
Rate [
|
]
 
 
dionak
To add to JT's comment, you could probably filter request by using a
regex on the IP, filtering out your interal IP's.

dionak

On Mon, Jul 7, 2008 at 8:36 PM,   wrote:
> JT wrote:
>
> Are you saying that you don't already know what your internal IP
> ranges are?
>
> $session->server gives you a reference to Apache2::ServerUtil, which
> can probably give you those IPs.
>
>> How can I query IPs of interfaces apache binds to? I need this to
>> distinguish between internal and external requests in the
>> userSession table.
>>
>
>
>
>
> JT Smith
> ph: 703-286-2525 x810
> fx: 312-264-5382
>
> Create like a god. Command like a king. Work like a slave.
>
>
>
> http://www.plainblack.com/webgui/dev/discuss/ips-of-interfaces-apache-binds-to/3
>
>
> --
>
>
>
> Plain Black, makers of WebGUI
>
> http://plainblack.com
>
>
>



--
Knowmad Technologies - Open Source Software Solutions
W: http://www.knowmad.com | E: diona@knowmad.com
P: 704.343.9330 | http://www.LinkedIn.com/in/dionakidd


Back to Top
Rate [
|
]
 
 
apeiron
On Jul 7, 2008, at 20:30 :35,    
wrote:

> dionak wrote:
>
> To add to JT's comment, you could probably filter request by using a
> regex on the IP, filtering out your interal IP's.


I would probably go with http://search.cpan.org/~frajulac/Net-IPv4Addr-0.10/IPv4Addr.pm
 to keep things simple and maintainable. Yes, it's an encapsulation  
of some regexes (although it uses unpack in several places), but it's  
a *readable* encapsulation. :)

Chris Nehren // Plain Black
p 1.703.286.2525 x 811
m 1.267.573.1000
f 1.312.264.5382



Back to Top
Rate [
|
]
 
 
bernd

Are you saying that you don't already know what your internal IP ranges are?

$session->server gives you a reference to Apache2::ServerUtil, which can probably give you those IPs.

$session->server returns an object of type Apache2::ServerRec, in fact. The documentation of this field is incorrect and should be updated

If someone was interested, the following code is what I had been looking for:

# Query server hostname
my $hostname = $session->server->server_hostname();

# Look up server IP addresses
my $ip_clause;
my $res = Net::DNS::Resolver->new();
my $query = $res->search($hostname);
if ($query)
{
    foreach my $rr ($query->answer)
    {
        next unless $rr->type eq "A";
        # Generate SQL clause which excludes server IPs
        $ip_clause = $ip_clause . " AND STRCMP(lastIp, '" . $rr->address . "')";
    }
}

$ip_clause can now be added to SQL queries in order to filter out server ips.



Back to Top
Rate [
|
]
 
 
     Discuss > WebGUI Dev



Recent Discussions Color Key

Design:

Development:

Et Cetera:

Install/Upgrade:  

Smoketest:

Template Group:


Smoke Test for WebGUI (Stable) (2008-11-21) by botaction - Fri @ 12:37am

Re: Site paid for by advertizing by pwrightson - Thu @ 10:59am

Re: Site paid for by advertizing by JT - Thu @ 08:58am

Re: Regelmäßiger Termin für Usertreffen in der Rhein-Neckar-Region by Klaus - Thu @ 06:11am

Smoke Test for WebGUI (Stable) (2008-11-20) by botaction - Thu @ 12:00am

Smoke Test for SVN (2008-11-20) by botaction - Thu @ 12:00am

Re: Improving page layouts by fdillon - Wed @ 08:38pm

Re: Improving page layouts by knowmad - Wed @ 08:25pm

Re: Site paid for by advertizing by knowmad - Wed @ 08:07pm

Re: SSL Configuration? by knowmad - Wed @ 07:51pm

Re: The Death of the Collaboration System by preaction - Wed @ 07:39pm

SSL Configuration? by dwittenberg - Wed @ 04:16pm