Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Testing for a firewall

by akm2 (Scribe)
on Aug 22, 2001 at 19:10 UTC ( [id://106977]=perlquestion: print w/replies, xml ) Need Help??

akm2 has asked for the wisdom of the Perl Monks concerning the following question:

My fellow monks I have yet another question to put before you.

I need a .cgi that will test and see if a user is behind a firewall. If so I need to make sure that ports 3380 and 3389 are not blocked. if they are blocked, I need to display an error message.

I need this script so I can test and see if said user is going to be able to connect to our Windows 2000 Terminal Server.

Can anybody give me some example code, ideas, thoughts, or advice on how to do this?

Thanks in advance,

Andrew Kenton Mitchell
Andrew@AndrewKMitchell.com

Replies are listed 'Best First'.
Re: Testing for a firewall
by echo (Pilgrim) on Aug 22, 2001 at 19:15 UTC
    The client might be able to connect to port 3380, while a connection from the server to the client might be forbidden. In other words the firewall might (and they usually do) implement a different ruleset for outgoing connections and incoming ones. Therefore I wager there is no way you can achieve what you want, short of asking the client to connect (or triggering that with a Java applet) and seeing if it comes through.
Re: Testing for a firewall
by MZSanford (Curate) on Aug 22, 2001 at 19:12 UTC
    Hmmmm, If you want to be able to connect to them on ports 3380 and 3389, i would probably use IO::Socket and open a connection with a short (maybe 10 sec ?) timeout, and then use the return code to say if the ports are open. About the only real way i can think of.

    but, if i am confussed, and i am quite a bit lately, and you want to find out if they could connect to you ... i am not sure of anyway ... but, i am not a CGI programmer.

    Update : Could you possibly pop another browser window to another http server on port 3380 of you machine (or any machine) and ask the user to confirm that that has loaded ? but, beware, users lie
    can't sleep clowns will eat me
    -- MZSanford

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2024-04-18 03:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found