ritesh thakur wrote:
I am using this code to block a port.
It says port has been blocked. but for eg. if I block port port 80, http sites are opening, while http:// sites work on port 80.
Paul Clapham wrote:Hi ritesh, welcome to the Ranch!
Your post is a little unclear to me: did you mean to say that you tried to block port 80 on your computer by running that code you posted, and then you found that connecting to HTTP sites on some other computer that you could still do that?
Henry Wong wrote:
ritesh thakur wrote:
I am using this code to block a port.
It says port has been blocked. but for eg. if I block port port 80, http sites are opening, while http:// sites work on port 80.
And technically, this isn't blocking a port. The application is basically binding to a local port, which disallows anyone else from using that same port. Blocking a port is selective, allowing certain clients to use the service, while blocking others from getting to the service. Since the application uses the port, the service can't use it. You can achieve the same affect by just not starting the service.
Henry
when i now try to access http:// sites on the same computer where i have blocked port 80
when i now try to access http:// sites from the same computer where i have blocked port 80
Paul Clapham wrote:I'm guessing that when you say
when i now try to access http:// sites on the same computer where i have blocked port 80
You really mean
when i now try to access http:// sites from the same computer where i have blocked port 80
Or are these http:// sites really hosted on the computer where you blocked port 80?
Ulf Dittmer wrote:That's not what this code does. As Henry explained, it blocks any process from binding to port 80 - thus no process (in particular no HTTP server, since that's what generally uses port 80) can serve anything on port 80 on that machine.
That is entirely unrelated to which ports on other machines any process (like a web browser) can access from that machine. The inbound port is not the same as the outbound port.
Coding something is not the right way to go about this. Either block outgoing HTTP connections from this machine at your network router (or switch or firewall), or use iptables (on *nix) or the firewall built into Windows to block this kind of traffic.
ritesh thakur wrote:
that helped. thanks ulf dittmer. but as you said:
" it blocks any process from binding to port 80 - thus no process (in particular no HTTP server, since that's what generally uses port 80) can serve anything on port 80 on that machine."
so now no HTTP server, can serve on that port. so how can these sites open.? (machine on which 80 is blocked is same machine on which http sites are still opening)
ritesh thakur wrote:
so can i achieve, blocking http:// sites using java or it is not possible.?