Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to block all incoming and outgoing traffic on a Windows XP host via batch file?

Bonus question, I only want to allow 1 outgoing port and all traffic going over that port.

share|improve this question
Clarify the "bonus question". Do you mean you want the machine to act as normal and make all normal traffic use a single port?! – Ben Campbell Nov 30 '11 at 22:21

You can set it using group policy instead of a batch file.

share|improve this answer
It's a standalone machine, no group policy. – Tnkflx Nov 30 '11 at 16:26

Use netsh advfirewall firewall command to configure windows firewall. See for details.

share|improve this answer

Even if there would be such a command (and there isn't), then you can't block outgoing traffic, as only the newer Windows versions have outgoing firewall support. Use a recent version of Windows.

share|improve this answer

The only method that occurs to me directly via bat file is using netsh commands to severely restrict the internal network settings... filtering and such. I'm still not convinced this will work the way you want. I'm not sure why you would use a bat file method when you could just use a software firewall and just whitelist the traffic as you see fit. However, you may be able to enable or disable a firewall configuration with a bat file that could have the desired effect.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.