Skip to content

promatcloud/PromatWindowsFirewallManagement

Repository files navigation

promat
PromatWindowsFirewallManagement

Build status NuGet Badge

Library to add or remove rules to windows firewall from c# code.

PromatWindowsFirewallManagement is available by NuGet PromatWindowsFirewallManagement

Generalidades

The library is implemented in netstandard 2, so it can be used in all types of projects:

Both in core and full framework we have to instantiate the WindowsFirewallRule class,  
on it we can define the configuration of the rule.

In the configuration we have to take into account that the Name, Dir and Action parameters are mandatory

Once configured we can use its AddRule method to add the rule or DeleteRule to delete it.

Net Core & Full Framework

Configuration:

       var rule = new WindowsFirewallRule
       {
         Name = "Microsoft SQL Server 2014 TCP Port 1433",
         Dir = DirEnum.In,
         Action = ActionEnum.Allow,
         Protocol = ProtocolEnum.Tcp,
         Profile = ProfileEnum.Private | ProfileEnum.Domain
       };
       rule.AddLocalPorts(1433);

Add / Delete:

       rule.AddRule();               
       rule.DeleteRule();

About

Library to add or remove rules to windows firewall from c# code.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages