Windows Firewall – Creating list of ports using bash

Today I tried to add…

Login

Blog History

Today I tried to add a firewall rule in Windows 2008 using syntax such as 1024-2000 and got an error message saying that I had to specify the ports correctly.

Seems that it doesn't allow an inclusive range but you need to specify each port individually such as 1024,1025, etc. I don't know about you but I have better things to do than do that manually.

Using Bash under Cygwin:

for i in {1024..2000} ; do echo -n $i, ; done > list.txt
# then open list.txt in notepad.exe remove 
# the trailing comma and copy and paste the
# list into Windows Advanced Firewall GUI

Using a VBS Scriptlet:


' copy this into a vbs script and run 
' from command prompt using cscript yourscriptname.vbs
for i = 1024 to 2000
	port_list = port_list & i & ","
next

' trim the trailing comma
wscript.echo left( port_list, len(port_list )-1)

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.