Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 21st, 2001, 12:25 PM
Kimppa Kimppa is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2001
Location: Finland
Posts: 711 Kimppa User rank is Sergeant Major (2000 - 5000 Reputation Level)Kimppa User rank is Sergeant Major (2000 - 5000 Reputation Level)Kimppa User rank is Sergeant Major (2000 - 5000 Reputation Level)Kimppa User rank is Sergeant Major (2000 - 5000 Reputation Level)Kimppa User rank is Sergeant Major (2000 - 5000 Reputation Level)Kimppa User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 5 Days 19 h 19 m 54 sec
Reputation Power: 35
Question IP and hostmask

I'm making a web portal that has restricted amount of users.
Now, I need to increase the security on this site, and I've decided to use IP and hostmask for that.
My problem is that I don't know how to get a user's IP or hostmask with Perl.
Could someone tell me how to get it?

- Kimppa
__________________
Fatal error on row 561: Couldn't access life - life isn't set

Reply With Quote
  #2  
Old July 21st, 2001, 12:37 PM
Hero Zzyzzx's Avatar
Hero Zzyzzx Hero Zzyzzx is offline
11
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2001
Location: Lynn, MA
Posts: 4,635 Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 23 h 44 m 19 sec
Reputation Power: 77
Send a message via AIM to Hero Zzyzzx
The absolute easiest way is to use CGI.pm to retrieve this information from the environment variables. In fact, CGI.pm makes pretty much all CGI programming easier.

Code:
use CGI;
my $q= CGI->new();

my $ip_or_hostname=$q->remote_host();


This will put either the hostname of the client, or the IP if the hostname isn't available, into the $ip_or_hostname variable.

Please don't think that IP or hostname based security is the be-all end-all though, this stuff can be spoofed.

Building off your sig, the CGI.pm docs are at the address below:

http://stein.cshl.org/WWW/software/CGI/

Good luck!

Reply With Quote
  #3  
Old July 21st, 2001, 01:11 PM
Kimppa Kimppa is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2001
Location: Finland
Posts: 711 Kimppa User rank is Sergeant Major (2000 - 5000 Reputation Level)Kimppa User rank is Sergeant Major (2000 - 5000 Reputation Level)Kimppa User rank is Sergeant Major (2000 - 5000 Reputation Level)Kimppa User rank is Sergeant Major (2000 - 5000 Reputation Level)Kimppa User rank is Sergeant Major (2000 - 5000 Reputation Level)Kimppa User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 5 Days 19 h 19 m 54 sec
Reputation Power: 35
Ok, thanks, got the IP-thingie working.... but how about the hostmask?

I know that it isn't top-security to use only ip & hostmask control, but this thing I'm making doesn't need to be top-top-secure.

Reply With Quote
  #4  
Old July 29th, 2001, 01:10 PM
TBehling TBehling is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Posts: 0 TBehling User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
"Hostmask"

By "host mask", I assume you mean "network mask". You can't determine a client computer's netmask from another computer, and it would play no role in authentication.

If you're trying to limit access to a range of IP addresses, that's another question. If you're running Apache and want to restrict the site to machines in 192.168.1.???, put this in the .htaccess file in the directory you want to restrict:

Order allow,deny
Allow from 192.168.1.0/24

Read more about Apache's access control mechanisms at:

URL

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > IP and hostmask


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT