drlexa
drlexa

Reputation: 197

Ip address with the address 192.168.0.0 network in http request header

Using mod_perl for Apache 1.3. Address of the client get the headers X-Forwarded-For, HTTP_X_FORWARDED_FO,or environment variable $ENV{REMOTE_ADDR}:

sub address {
    my $self = shift;
    unless(defined $self->{address}){
        my $header = $self->apache->headers_in->{'X-Forwarded-For'} ||
            $ENV{HTTP_X_FORWARDED_FOR} || '';
        my ($ip) = $header =~ /([^,\s]+)$/;
        $self->{address} = $ip || $ENV{REMOTE_ADDR} || ''; 
    }
    return $self->{address};
}

The problem is that sometimes there are addresses such as 192.168.200.11, 192.168.1.156, 192.168.0.73. Although the server is not connected to the network 192.168.0.0.

Upvotes: 0

Views: 322

Answers (1)

Alexei Levenkov
Alexei Levenkov

Reputation: 100547

Expected as you are explicitly looking at HTTP_X_FORWARDED_FOR header that (if properly set by all proxies on a way) will contain all intermediate IP and original client IP. Since most people are in local home networks most originating IPs are in 192.168.xx.xx range.

Upvotes: 1

Related Questions