Restrict IP access to a Perl application
- From: barramundi9 <barramundi9@xxxxxxxxxxx>
- Date: Tue, 29 Jan 2008 23:04:26 -0800 (PST)
Dear all:
I am a newbie to Perl and have an application written in Perl. I put
IPs that are "allowed" to access the application into a file called
"ip.allow".
I then tried to compare the $ENV{REMOTE_ADDRESS} to the IPs in
"ip.allow" to determine the access right which looks like the
following:
10.0.0.1
10.0.0.2
10.0.0.3
And the code is:
$address=$ENV{'REMOTE_ADDR'};
open(FILE,"/path/to/ip.allow") or die ("Cannot open file!");
flock(FILE,2);
while ($line=<FILE>) {
$line=~s/\./\\\./g;
if ($line =~ /$address/) {
print "IP matched!!\n";
last;
}
}
flock(FILE,8);
close(FILE);
But it doesn't seem to work because when I take out 10.0.0.1 from the
ip.allow file, 10.0.0.1 can still access the application.
Any suggestions are appreciated, thanks.
barramundi9
.
- Follow-Ups:
- Re: Restrict IP access to a Perl application
- From: Abigail
- Re: Restrict IP access to a Perl application
- From: Dave Weaver
- Re: Restrict IP access to a Perl application
- From: Martijn Lievaart
- Re: Restrict IP access to a Perl application
- From: John W. Krahn
- Re: Restrict IP access to a Perl application
- Prev by Date: Re: List of directories within a directory
- Next by Date: Re: Restrict IP access to a Perl application
- Previous by thread: FAQ 8.40 How do I avoid zombies on a Unix system?
- Next by thread: Re: Restrict IP access to a Perl application
- Index(es):
Relevant Pages
|
|