Dumb question:
Is there an equivalent of iptables on Windows? Could I install one via cygwin?
The real question: how can I accomplish on Windows what I can accomplish via iptables? Just looking for basic firewall functionality (e.g. blocking certain IP addresses)
One way would be with the
netsh
command:netsh firewall
(deprecated after XP and 2003)netsh advfirewall
(Vista, 7, and 2008)The below is from: https://support.microsoft.com/en-us/kb/947709
Example 1: Enable a program
Old command New command
Run the following commands:
For more information about how to add firewall rules, run the following command:
Example 2: Enable a port
Old command New command
For more information about how to add firewall rules, run the following command:
Example 3: Delete enabled programs or ports
Old command New command
For more information about how to delete firewall rules, run the following command:
Example 4: Configure ICMP settings
Old command New command
For more information about how to configure ICMP settings, run the following command:
Example 5: Set logging
Old command New command
netsh firewall set logging %systemroot%\system32\LogFiles\Firewall\pfirewall.log 4096 ENABLE ENABLE
Run the following commands:For more information, run the following command:
If you want to set logging for a particular profile, use one of the following options instead of the "currentprofile" option:
Domainprofile
Privateprofile
Publicprofile
Example 6: Enable Windows Firewall
Old command New command
Run the following commands:
Run the following commands:
For more information, run the following command:
If you want to set the firewall state for a particular profile, use one of the following options instead of the "currentprofile" option: Domainprofile
Privateprofile
Publicprofile
Example 7: Restore policy defaults
Old command New command
For more information, run the following command: netsh advfirewall reset ? Example 8: Enable specific services
Old command New command netsh firewall set service FileAndPrint netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=Yes netsh firewall set service RemoteDesktop enable netsh advfirewall firewall set rule group="remote desktop" new enable=Yes netsh firewall set service RemoteDesktop enable profile=ALL Run the following commands:
netsh advfirewall firewall set rule group="remote desktop" new enable=Yes profile=domain
netsh advfirewall firewall set rule group="remote desktop" new enable=Yes profile=private
WIPFW looks very promising, especially if your after that iptables rule creation flavor.
There is a built-in firewall in XP, Server 2003 and later releases.
It has an API through which you can programatically change, enable, and disable rules.