Hi there,
I need to block port 80 (HTTP for internet). Is there a way to block give socket?
Thanks!

Recommended Answers

All 9 Replies

I'm not sure you understand ports entirely, I couldn't gather that from your post.
To clarify;
Your computer won't make the outgoing connection on port 80. It will choose some random high number port. Port 80 is the INBOUND port for a HTTP server, but it doesn't necessarily have to be port 80. I could tell my browser to go to port 3001 and if a web server was running there it would give me back HTML.

In most cases your best bet is to install a firewall (which can block inbound and outbound traffic depending on its destination). If you need to do this programatically then I suggest google searching on how to build a firewall. (It will involve packet sniffing) =)

Aha, you're right!
I was reading this and found that I was talking as if I wan't to block the server. So now the question changes to HOW TO CODE SIMPLE PROXY SERVER That block internet?

Thanks

When you say block the internet, what exactly do you want? The internet is an International Network and does not solely consist of Websites. (example; Voice Over IP, FTP, SMTP etc.)

What is the final goal of what you wish to achieve? Please describe it in detail and I'll try and provide you with the best way to go about it.

EDIT: If you truly wish to block the internet, write an application or script that removes the default gateway from the network adapter configuration. This will effectively "block" outbound connections to the internet.

I was discussing with a friend and he suggested that I block protocol (HTTP).
Is there a way to do that?

Yes, but again, you need to consider what the final goal is. There are plenty of free firewall applications out there that will do what you want.

If you want to go and do this yourself there will be a rather steep learning curve.

In order to do what you ask you will need to intercept all packets coming from the machine, decode them, find which protocol they use and then filter out all the HTTP traffic.

To get you started, here's a handy link

Ok here is what I want to achieve. I need to block all Internet traffic, Emails (SMTP), and FTPs I should be able to re-enable it also programatically. Your method of removing gateway seems good. will you explain a little bit?

Ok, there's a one line command you can use to remove the gateway from the network adapter (which can be done from the command prompt): netsh interface ip set address local static gateway=none

Is this disable all port or it is used to close port 80 only????

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.