How to detect programmatically if my machine is behind a firewall

S

Swaroop Kumar

Hello:

Is it possible to programmatically (in Java, of course) detect if
my machine is running behind a firewall or a router? I would
appreciate any help/tips/pointers/advice that you can provide. A
potentially silly way would be to send an HTTP request to
http://www.whatsmyip.com and compare the IP address in the response to
the one that I think I have (maybe determined by creating a socket?).

Thanks in advance,
Swaroop
 
N

nos

chances are pretty high that there is a router between your
machine and sites on the internet.
 
J

Jeeves

(e-mail address removed) (Swaroop Kumar) wrote in
Sorry if I didn't make my meaning clear, but by "my", I meant the
machine that the program runs on, not specifically my machine. We
are in the design stages of a program that will run in large
institutions, which could have machines with class A or class B
subnet addresses and may not be behind a router.

Everyone is "behind a router". Are you trying to find out if there's a
NAT device or application between the network and the destination
address?
 
S

Swaroop Kumar

Thanks for the quick reply.

Sorry if I didn't make my meaning clear, but by "my", I meant the
machine that the program runs on, not specifically my machine. We are
in the design stages of a program that will run in large institutions,
which could have machines with class A or class B subnet addresses and
may not be behind a router.

Thanks again,
Swaroop
 
M

Missaka Wijekoon

Hi,

No it is not possible. BTW, if you need to talk to any machine on the
internet, then by definition you must be behind a router - no
exceptions. But I think what you mean is a firewall, NAT (network
address translation) or proxy server, right?

You can do a few things to guess:

* if your ip is 192.X.X.X or 10.X.X.X then you have a private ip address
and if you need to talk to any other machine on the internet, you must
be behind a router/firewall/proxy that is doing NAT.

* see if your JVM is using SOCKS, or a proxy to get at web addresses. If
so you are behind a firewall.

* attempt to make connections to a known ip address on the internet.
Connect with http, https, telnet, and some other arbitrary ports. Based
on the successes and/or failures you can determine the nature of the
firewall.

* if you can, obtain the routing info for your server. I am unsure as
to how to do this directly from Java, however the following command on
UNIX and Windows (I think - NT/2000/XP) will reveal routes, interfaces,
and gateways (router/firewall):

netstat -rn

Cheers,
Misk



Swaroop said:
Thanks for the quick reply.

Sorry if I didn't make my meaning clear, but by "my", I meant the
machine that the program runs on, not specifically my machine. We are
in the design stages of a program that will run in large institutions,
which could have machines with class A or class B subnet addresses and
may not be behind a router.

Thanks again,
Swaroop


--
========================================================================
Missaka Wijekoon (a.k.a. Misk) (e-mail address removed)
Sr. Software Engineer http://www.villageEdocs.com
VillageEdocs
========================================================================
 
Joined
Feb 9, 2009
Messages
1
Reaction score
0
detect the firewall by web page

hi
i need the same ,is anybody have the solution ,please let me know awating for your positive reply

best regards,

Sujith
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top