The Windows Firewall and Business Applications — Register Inbound Rules From the Installer
· Go Komura · Windows, Firewall, Network, Security, Business Applications, Installer, PowerShell, Information Systems
“It works fine on the dev machine, but once we installed it at the client’s site the client couldn’t connect to the server.” “Some warning popped up on first launch, and it sounds like whoever was there cancelled it.” “netstat shows the port is listening, but it’s unreachable from the PC next door.” — in the field of business app rollouts, complaints of this shape are the classic of classics. And sitting near the top of the list of causes, persistently, is the Windows Firewall (Windows Defender Firewall).
What makes it awkward is that the problem is invisible on the dev machine. On the dev machine you clicked “allow” yourself while debugging in Visual Studio, or you were simply an administrator to begin with, so you ship without ever noticing the default inbound block. At the client’s site, on the other hand, the person operating the machine is an ordinary user without administrator rights, and the network is managed by GPO. It is not that “something that should work doesn’t” — the reality is that “the dev machine just happened to work”.
This article is aimed at business-app developers who run into “can’t connect at the client’s site” with their own in-house apps, and at the IT staff at small and mid-sized companies who field those complaints. After covering the minimum you need to know about the Windows Firewall’s default behaviour and its profile mechanism, it works through inbound rule design, the practicalities of registering rules from an installer, triage procedures, and the caveats that apply under GPO/Intune management — all grounded in primary sources as of August 2026.
1. The Bottom Line First
- The Windows Firewall’s default is “block inbound, allow outbound”. Inbound traffic that is not a response to a request is discarded unless it matches a rule.1
- An inbound rule is only needed for server-type apps that listen on a port. A client app that merely initiates connections works under the defaults as-is. Start your triage here.1
- There are three profiles (Domain/Private/Public). Domain is applied automatically when a domain controller is detected; Public is the default for unidentified networks. Rules are enabled or disabled per profile.1
- You cannot leave production to that “security alert” dialog. If an administrator cancels it, a block rule is created; for a user without administrator rights, a block rule is created no matter which button is pressed. The dialog will not reappear until the created rule is deleted.2
- The conclusion is: register a business app’s inbound rules from the installer. Microsoft itself recommends placing the rule before first launch and disabling the inbound notification.2
- Design rules around minimal privilege. Build around program + protocol + port, restrict the profile to Domain/Private, and restrict the remote IP to the required subnet. Wildcards cannot be used in a program path.23
- Triage in the order Test-NetConnection → Get-NetFirewallRule → pfirewall.log. The firewall log is not written by default — it only appears once you enable logging of discarded packets.456
- Blanket disabling by stopping the service is unsupported. Under GPO/Intune management, “local rule merging” may be disabled, in which case local rules have no effect. Request centralised rule distribution from IT.12
2. Getting the Default Behaviour Right — Inbound Is Blocked by Default, Outbound Is Allowed by Default
Start by getting the foundation right. The Windows Firewall is a host-based firewall enabled by default in every edition, and its default behaviour comes down to these two lines.1
- Inbound: blocked entirely, unless it is a response to a request (solicited) or it matches a rule
- Outbound: allowed entirely, unless it matches a rule
These two lines give you the most important triage question for a business app: an inbound rule is only needed for the side that “listens”.
- A client app that only connects out to an in-house web server, database server, or core system → as a rule, no rule needed. Return packets for a connection you initiated count as a “response to a request” and pass by default.
- A server-type app or Windows service that opens a port and listens for connections over TCP, gRPC, a custom protocol, or similar → an inbound rule is mandatory.
- One exception is worth noting: a setup that uses named pipes remotely. A remote named pipe does not go through a port owned by the app itself — it goes through SMB (TCP 445) — so what is needed is not a rule for the app but a rule on the file-sharing (SMB) side.
- The other exception is high-security environments that explicitly change the outbound default to block. This configuration exists in only some organisations, but where it does, even client apps need an outbound rule requested for them.2
flowchart TB
APP["Inventory your own app's communication"] --> Q{"Does it open a port and<br/>listen for connections?"}
Q -- "No listening -<br/>connects only as a client" --> C1["Inbound rule generally not needed<br/>Return traffic passes as a response"]
Q -- "Listens -<br/>server-type or callback receiver" --> S1["Inbound rule mandatory<br/>-> register from installer, Section 5"]
C1 -.-> EX["Exception - in high-security environments<br/>with outbound blocked by default, request an outbound rule"]
The case of “an app that’s supposed to be a client but is actually listening too” (receiving result callbacks, acting as a notification endpoint for another process, and so on) is easy to overlook. If it is unclear which communication style your own app is listening on, it is worth checking “Choosing Windows Inter-Process Communication” as a design-stage reference.
2.1. Profiles and the “Network Location”
Rules apply per network profile. There are three profiles.1
| Profile | When it applies | Typical location |
|---|---|---|
| Domain | Applied automatically when an AD-domain-joined PC detects a domain controller. Cannot be set manually | Corporate domain network |
| Private | Set manually on a network interface by an administrator | Home or small-office LAN |
| Public | Default for unidentified networks. Designed around the strictest assumptions | Public Wi-Fi, hotels, airports |
You can check which profile currently applies with Get-NetConnectionProfile, and switch between Private and Public with Set-NetConnectionProfile.1 A common incident in the field is that the network at the client’s site, in a workgroup environment, gets classified as “Public”, so an inbound rule built for Domain/Private only does not apply. When “the rule exists but traffic doesn’t get through”, suspect a profile mismatch before you suspect the rule’s contents.
2.2. Rule Precedence
When multiple rules exist, evaluation is not decided by a weighted ordered list but by the following consistent principles.2
- An explicit allow rule takes precedence over the default block
- An explicit block rule takes precedence over a conflicting allow rule
- Within the bounds of rule 2, a more specific rule takes precedence
The practical implication is that “once a single block rule exists anywhere, no amount of allow rules added afterwards will beat it.” As the next section shows, it is exactly this kind of block rule that the dialog quietly creates.
3. What the “Security Alert” Dialog Really Does — Why You Can’t Leave It in Charge
The first time an app starts listening on a port, if there is no allow rule for that app — administrator-defined or otherwise — Windows shows the familiar “Windows Security Alert” dialog stating that “some features of this app have been blocked by Windows Defender Firewall”. The specification of its behaviour is unambiguous.2
- Shown to a user with administrator rights: clicking “Allow access” creates an allow rule. But clicking “Cancel” creates a block rule — normally two, one for TCP and one for UDP.
- Shown to a user without administrator rights: a block rule is created no matter which option is chosen.
- In either case, once a rule has been created the dialog never appears again unless that rule is deleted, and communication remains blocked.
flowchart TB
L["App starts listening on a port"] --> Q1{"Is there a rule<br/>matching that app?"}
Q1 -- "Yes" --> R1["Follows the rule<br/>(no dialog shown)"]
Q1 -- "No" --> Q2{"Is inbound<br/>notification enabled?"}
Q2 -- "Disabled" --> R2["Blocked silently<br/>(no rule created)"]
Q2 -- "Enabled" --> DLG["Security Alert dialog"]
DLG -- "Administrator clicks Allow access" --> OK["An allow rule is created"]
DLG -- "Administrator clicks Cancel" --> NG1["A block rule is created"]
DLG -- "Non-administrator user<br/>(any choice)" --> NG2["A block rule is created"]
NG1 --> NEVER["Dialog never shown again<br/>until the rule is deleted"]
NG2 --> NEVER
In other words, this dialog looks like “a mechanism that asks the user for permission”, but in a business-app setting it works as “a mechanism that burns in a block rule the moment an ordinary user touches it”. If the person installing the app launches it for the first time under an administrator account and clicks Allow on the dialog, the allow rule that gets created applies machine-wide, so ordinary users from the next day onward can also communicate — for now. Even so, an incident risk remains: the first time an ordinary user hits a listening path the rollout verification never exercised, when the applied network profile differs from the one at install time, or when an update changes the exe path (Sections 4 and 5).
Microsoft itself spells out the following best practice for devices used by non-administrators.2
- Place the required rules before the app’s first launch (via the installer or centralised distribution)
- Disable the inbound notification (turning notifications off stops the automatic runtime rule creation altogether)
You can disable notifications with Set-NetFirewallProfile -NotifyOnListen False, or via Group Policy.7 “If the dialog pops up, have the person on site click Allow” is not an operating procedure — it is a scheduled incident. Register inbound rules at install time — that is this article’s conclusion, and it matches Microsoft’s own recommendation.
4. Designing Inbound Rules — By Program, by Port, and by Service
Now for the substance of the rule you register. There are broadly three ways to specify a rule’s target, and you decide whether to use one alone or combine them.
| Method | Suits | Weaknesses / caveats |
|---|---|---|
Program-based (program= / -Program) |
Listening port is dynamic or multiple. A desktop app binary itself does the listening | Only a full exe path — no wildcards2. If an update changes the path, the rule loses its target (Section 5.4) |
Port-based (localport= / -LocalPort) |
Port is fixed. Easier to align with a request to IT and with network device configuration | Also lets through any other process listening on the same port. Requires a port-number registry |
Service-based (-Service) |
A listening process running as a Windows service | Targets by the service’s short name3. Does not apply to a directly launched exe |
| Combined (program + protocol + port) | The standard shape for a production business app | The more conditions you add, the more fragile it becomes against environment changes (path/port), so document the rule’s contents2 |
On top of that, layer in further scope restrictions. Microsoft’s own design guidance is likewise “make inbound rules as specific as possible”.2
- Restrict the profile: for a business app used only within the company, restrict the inbound rule to Domain/Private and do not enable it under Public. This prevents the incident where a listening port opens to the world the moment a laptop connects to outside Wi-Fi.
- Restrict the remote IP: if the source is known, restrict
-RemoteAddressto that subnet. For home and small networks, restricting with theLocalSubnetkeyword is recommended.23 - Direction and count: if listening is TCP-only, a single TCP rule is sufficient. Do not casually create both TCP and UDP rules the way the dialog does automatically.
“From the parties who need it, to the port that’s needed, for only the program that needs it” — that single sentence of minimal privilege is the whole of inbound rule design.
5. The Practicalities of Registering From an Installer — netsh and New-NetFirewallRule
5.1. Prerequisite: Administrator Rights Are Required
Adding or removing firewall rules is a machine-wide configuration change, so it must be run with administrator rights (an elevated process).8 An installer normally runs elevated already, so it makes sense to place rule registration inside the install process. This is not a reason to run the app itself as administrator — the reasoning behind that boundary is covered in detail in “When Do You Actually Need Administrator Privileges on Windows?”.
5.2. Registering With netsh advfirewall
The classic approach, and easy to call from any installer, is netsh advfirewall firewall add rule.8
rem "add rule" appends even if a rule of the same name already exists, so to
rem prepare for reruns on reinstall, repair, or update, delete the same-name
rem rule first and register it fresh
netsh advfirewall firewall delete rule name="MyCompany OrderServer"
rem Inbound allow rule combining program + port + profile restriction
netsh advfirewall firewall add rule name="MyCompany OrderServer" dir=in action=allow program="C:\Program Files\MyCompany\OrderServer\OrderServer.exe" protocol=TCP localport=50051 profile=domain enable=yes
rem At uninstall: delete by name
netsh advfirewall firewall delete rule name="MyCompany OrderServer"
add rule does not replace an existing rule of the same name — it appends another rule under the same name — so unless you run delete rule first, rules multiply on every rerun, and old allow rules survive even after an update changes the path or scope (on the very first run, the leading delete rule reports “no rules match the specified criteria”, but batch execution continues, so this ordering is fine as-is. If your installer determines success or failure from an exit code, check the result of the trailing add rule instead). You can also scope the source with something like remoteip=157.60.0.1,172.16.0.0/16,LocalSubnet.8 Deletion removes every rule matching the given name in one go, so it is safer to make rule names unique with your own company prefix.
5.3. Registering With PowerShell (New-NetFirewallRule)
For finer control, use the NetSecurity module. -DisplayName is required, and -Profile accepts multiple values as a comma-separated list with no spaces.3
# Register (run elevated from the installer). -Name is the unique identifier,
# so rerunning on reinstall, repair, or update would error out trying to
# create a rule of the same name again. Make it idempotent by removing any
# existing rule of the same name first
Remove-NetFirewallRule -Name "MyCompany-OrderServer-In" -ErrorAction SilentlyContinue
New-NetFirewallRule -Name "MyCompany-OrderServer-In" `
-DisplayName "MyCompany OrderServer (TCP 50051 inbound)" `
-Direction Inbound -Action Allow `
-Program "C:\Program Files\MyCompany\OrderServer\OrderServer.exe" `
-Protocol TCP -LocalPort 50051 `
-Profile Domain,Private -RemoteAddress LocalSubnet
# At uninstall: don't error if it doesn't exist
Remove-NetFirewallRule -Name "MyCompany-OrderServer-In" -ErrorAction SilentlyContinue
There is a reason -Name is specified explicitly here. -Name is the rule’s unique identifier, and if omitted a random value is assigned. The display name (-DisplayName) can change with locale, so Microsoft’s guidance is to use -Name as the key for locating a rule from a script.3 Treat a fixed -Name as mandatory so your uninstaller can reliably remove only its own rule.
5.4. When an Update Changes the exe Path
A program-based rule pins its target by full path. That means if an update changes the install location or exe name, the rule stays behind but loses its target, and listening gets blocked again. At that point the exe at the new path is treated as “an app with no rule”, so in an environment where notifications are enabled, the Section 3 dialog reappears and an ordinary user’s interaction burns in a block rule. In an environment where notifications have been disabled as recommended in Section 3, it fails silently, without even showing the dialog. This is an especially easy incident to hit with a layout that places files in a version-numbered folder, or a self-updating scheme where the install location moves.
flowchart TB
V1["Install v1.0<br/>Rule points at the exe in the v1.0 folder"] --> UP["Update deploys to the v1.1 folder<br/>The path of the running exe changes"]
UP --> MISS["The rule at the old path loses its target<br/>(rule still exists but has no effect)"]
MISS --> Q{"Is inbound<br/>notification enabled?"}
Q -- "Enabled" --> DLG["Dialog reappears<br/>An ordinary user's touch creates a block rule"]
Q -- "Disabled" --> SILENT["Blocked silently,<br/>no dialog at all"]
MISS -.->|"Fix"| FIX["Keep the path fixed across updates,<br/>or have the updater remove and re-register the old rule"]
The fix is simple, and comes down to one of the following:
- Fix the install location so the exe’s full path never changes across updates
- For an update that does change the path, have the updater delete the old rule and register a new one at the new path (run the Section 5.2/5.3 commands from the update process too)
For an MSI, the standard pattern is to build rule registration in as a custom action run after files are laid down (and, symmetrically, a removal custom action at uninstall). Toolsets such as WiX also offer extensions for declaring firewall rules declaratively. The right place to implement this depends on which distribution method you choose, so also see “Choosing a Windows App Distribution Method”. Antivirus false positives — another classic problem in client-site rollouts — are covered separately in “Handling Microsoft Defender False Positives”.
6. Troubleshooting — A Triage Flow for “Can’t Connect”
Fix the procedure to follow once a complaint comes in. The overall flow is as follows.
flowchart TB
S["Report: can't connect from the client"] --> N["Server side: netstat -ano"]
N -- "Not listening" --> APP["A problem upstream of the firewall -<br/>investigate the app/service side"]
N -- "LISTENING" --> T["Client side: Test-NetConnection"]
T -- "TcpTestSucceeded=True" --> OTHER["Reachability is fine -<br/>investigate the app layer, auth/protocol"]
T -- "False" --> P["Server side: Get-NetConnectionProfile -<br/>check the applied profile"]
P -- "Mismatched against the rule's target" --> FIXP["Review the rule's profile setting"]
P -- "Matches" --> R["Get-NetFirewallRule -PolicyStore ActiveStore -<br/>check for an allow rule / a stray block rule"]
R --> LOGCHK["Confirm drops (DROP) with pfirewall.log"]
| Step | Command / action | What to check |
|---|---|---|
| 1. Confirm listening (server side) | netstat -ano |
Is the target port LISTENING? If it isn’t listening at all, the problem is upstream of the firewall |
| 2. Confirm reachability (client side) | Test-NetConnection -ComputerName sv01 -Port 50051 |
Is TcpTestSucceeded True?4 |
| 3. Confirm profile (server side) | Get-NetConnectionProfile |
Does the currently applied profile match the profile the rule was enabled for?1 |
| 4. Confirm active rules (server side) | Get-NetFirewallRule -PolicyStore ActiveStore |
Is the intended allow rule among the rules “actually in effect” — including those from GPO? Is a dialog-created block rule mixed in?5 |
| 5. Confirm via log (server side) | pfirewall.log | Are packets addressed to the target port being discarded (DROP)?6 |
A note on step 4. Port and program conditions live on the filter object rather than on the rule itself, so to look up a rule from a port you have to query through the filter.57
# Look up rules related to port 50051
Get-NetFirewallPortFilter | Where-Object { $_.LocalPort -eq 50051 } | Get-NetFirewallRule
# Trace where a rule came from (local vs. GPO)
Get-NetFirewallRule -PolicyStore ActiveStore -TracePolicyStore |
Select-Object Name, DisplayName, PolicyStoreSourceType, PolicyStoreSource
The firewall log in step 5 (pfirewall.log) records nothing by default. Its default path is %windir%\system32\logfiles\firewall\pfirewall.log, the default maximum size is 4,096 KB, and it is only written once you enable either “log dropped packets” or “log successful connections”.6 On a single machine you can enable it as follows.6
netsh advfirewall set allprofiles logging droppedconnections enable
netsh advfirewall set allprofiles logging allowedconnections enable
The log is a text file recording, line by line, whether traffic was dropped (DROP) or allowed (ALLOW), the protocol, and the source/destination IP and port, so it can settle definitively whether “the client’s SYN arrived and was dropped” or “it never arrived at all”. Note that in an environment where logging is configured by policy, the log folder may lack the write permission it needs (FullControl for the mpssvc service) and the file may never get created, in which case you need to create the folder and grant the ACL manually.6
For deeper investigation, enabling the audit policy “Audit Filtering Platform Packet Drop” records security event 5152 on every drop. However, the event volume is extremely high, so Microsoft recommends using event 5157 (Filtering Platform Connection), which is logged per connection instead. Treat this as a tool for the duration of triage, not something to run continuously.9
Finally, let’s be explicit about the triage step you must not take. Disabling the firewall wholesale by stopping the firewall service (MpsSvc) is unsupported, and it causes OS-level problems such as the Start menu not working or Store app updates failing. If you absolutely need to disable it to check something, leave the service running and disable the profile with Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False, then restore it immediately after confirming.17 And once you have confirmed the firewall is the cause, the fix is adding a single correct rule — not making the disablement permanent.
7. Caveats Under Organisational Management — Environments Where Local Rules Don’t Apply, and How to Request Them Properly
There are environments where a rule registered by your installer has no effect, even though it was registered. Organisations that manage the firewall centrally through GPO or Intune (CSP) can disable “local rule merging” (AllowLocalPolicyMerge) per profile. When this setting is disabled, rules created by a local administrator — including your installer — are not applied, and rules for any app that needs inbound connections must be distributed centrally from GPO/CSP.2
flowchart TB
GPOR["Rules distributed via GPO/Intune"] --> EFF["The set of rules actually in effect<br/>(ActiveStore)"]
LOCAL["Rules created locally<br/>(including installer registration)"] --> Q{"Local rule merging<br/>(AllowLocalPolicyMerge)"}
Q -- "Enabled (default)" --> EFF
Q -- "Disabled" --> DROP["Rule exists but is not applied<br/>-> switch to centralised distribution via GPO/CSP"]
The realistic preparation, on the development/rollout side, is as follows.
- Design the installer’s rule registration so that it “does not fail” (registration itself succeeds regardless, so an error alone cannot detect this — build a post-install connectivity check into the procedure)
- Use step 4 of Section 6 (
-TracePolicyStore) to check whether the rules actually in effect are sourced from local or GPO5 - Once you know a given environment does not honour local rules, switch to requesting rule distribution from the IT department
Hand over the following set of information together when making the request. A firewall rule cannot be created without direction, program, port, and scope all together, so this table doubles as the “network specification” for a business application.
| Item | Example entry |
|---|---|
| Rule name (identifier) | MyCompany-OrderServer-In |
| Direction | Inbound |
| Program path | C:\Program Files\MyCompany\OrderServer\OrderServer.exe |
| Protocol/port | TCP 50051 |
| Remote IP range | 172.16.10.0/24 (segment where order-entry clients sit) |
| Profile | Domain only |
| Purpose/justification | Accepts connections from the order-entry client (business system name) |
| Decommission condition | Delete when this system is retired |
From the IT side, a request with this table and one without it are worlds apart in effort. Conversely, a bare “please open this port” request tends toward over-permissioning, as covered in Section 4. Note also that the communication requirements around file sharing and authentication in domain environments are shifting independently of the firewall, through separate tightening such as mandatory signing. See also “SMB Signing and LDAP Channel Binding”.
8. Summary
- The Windows Firewall’s default is block-inbound, allow-outbound. An inbound rule is only needed for server-type apps that listen; a pure client that only connects out generally needs none.
- Rules apply per profile (Domain/Private/Public). The prime suspect when “the rule exists but traffic doesn’t get through” is a profile mismatch.
- The “security alert” dialog creates a block rule on a cancel or on any action by a non-administrator user, and it never reappears afterward. Production operation must never be left to this dialog.
- Register a business app’s inbound rules from the installer — that is the one and only principle. Registration runs with administrator rights, and a fixed
-Nameshould be used throughout, including for removal. - Build rules around program + protocol + port, and narrow them with the profile and remote IP. Don’t forget to re-register the rule when an update changes the exe path.
- Triage mechanically in the order netstat → Test-NetConnection → profile check → Get-NetFirewallRule (ActiveStore) → pfirewall.log. Disabling by stopping the service is unsupported.
- Under GPO/Intune management, local rule merging may be disabled. When it is, request distribution from IT with the rule name, direction, program, port, remote IP, and profile all specified together.
Related Articles
- Choosing Windows Inter-Process Communication ── A Decision Table for Named Pipes / TCP / gRPC / Shared Memory / COM
- Choosing a Windows App Distribution Method - MSI/MSIX/ClickOnce/xcopy/Custom Updater
- When Do You Actually Need Administrator Privileges on Windows? - UAC, Protected Areas, and How to Tell by Design
- When Your In-House Windows App Gets Flagged as a Virus — Handling Microsoft Defender False Positives and Living With the Performance Impact
- SMB Signing and LDAP Channel Binding — Closing the “Other Half” of Your NTLM Defences in Practice
- How to Build and Operate Windows Services ── From Choosing Between Task Scheduler and Services to Turning a BackgroundService into a Windows Service
Related Consulting Areas
KomuraSoft LLC handles installer design for server-type business applications (including registering and removing firewall rules), investigating the cause of “can’t connect” at client sites, and organising network requirements with GPO-managed rollouts in mind. It is fine to start from the triage of “works on the dev machine but not at the client’s site”.
- Windows Application Development
- Bug Investigation & Root-Cause Analysis
- Technical Consulting & Design Review
- Contact
References
-
Microsoft Learn, Windows Firewall overview. On the Windows Firewall being a host-based firewall enabled by default in every edition; the default behaviour being “inbound blocked unless it is a response to a request or matches a rule, outbound allowed unless it matches a rule”; the three profiles (Domain — applied automatically when a domain controller is detected, cannot be set manually; Private — set manually by an administrator; Public — the default for unidentified networks); checking and changing the network category with Get-NetConnectionProfile / Set-NetConnectionProfile; disabling via stopping the firewall service (MpsSvc) being unsupported and causing issues such as the Start menu failing or Store app updates failing; and the correct disabling method being to disable the profile while leaving the service running. ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9
-
Microsoft Learn, Windows Firewall rules. On rule precedence (an explicit allow takes precedence over the default block, an explicit block takes precedence over an allow, a more specific rule takes precedence, with no weighted ordering); the dialog appearing when an app starts listening with no matching rule; an administrator choosing “No” or Cancel creating a block rule (typically two, for TCP and UDP); a non-local-administrator user getting a block rule regardless of choice; the dialog not reappearing until the created rule is deleted, leaving communication blocked; it being common for the app or its installer to add the rule itself; the recommendation to place the rule before first launch and disable inbound notifications; program rules not supporting wildcards (e.g. C:*\teams.exe) and requiring a full path; local rule merging (AllowLocalPolicyMerge) being disableable per profile, with centralised distribution of rules for inbound-requiring apps becoming mandatory when disabled; the recommendation to make inbound rules as specific as possible and to restrict remote address to LocalSubnet for home/small networks; and outbound-block-by-default being an option for high-security environments, while the inbound default must never be switched to allow. ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11 ↩12 ↩13
-
Microsoft Learn, New-NetFirewallRule (NetSecurity). On -DisplayName being required when creating a rule; -Name being the unique identifier, defaulting to a random value, with guidance to use -Name from scripts; the specification of each parameter — -Direction (Inbound/Outbound), -Action (Allow/Block), -Program (full path), -Protocol (TCP/UDP/ICMPv4/ICMPv6/number), -LocalPort, -RemoteAddress (IP/subnet/range/keywords such as LocalSubnet), -Service, and -Profile (Any/Domain/Private/Public, comma-separated with no spaces for multiple values) — and an example rule combining program, protocol, and port. ↩ ↩2 ↩3 ↩4 ↩5
-
Microsoft Learn, Test-NetConnection (NetTCPIP). On Test-NetConnection being a cmdlet that displays diagnostic information for ping, TCP connections, and routing; -ComputerName and -Port testing a TCP connection to the specified port; and the result being returned as TcpTestSucceeded. ↩ ↩2
-
Microsoft Learn, Get-NetFirewallRule (NetSecurity). On -PolicyStore ActiveStore retrieving rules from every policy store currently applied (the resulting policy set, including those from GPO); conditions such as port and address living on the filter object rather than the rule itself, queried via Get-NetFirewallPortFilter / Get-NetFirewallApplicationFilter; and -TracePolicyStore allowing you to confirm a rule’s source (PolicyStoreSource / PolicyStoreSourceType, Local or GroupPolicy). ↩ ↩2 ↩3 ↩4
-
Microsoft Learn, Configure Windows Firewall logging. On the log’s default path being %windir%\system32\logfiles\firewall\pfirewall.log; the default maximum size being 4,096 KB, with the oldest entries deleted once the limit is reached; the log not being written until either “dropped packets” or “successful connections” is enabled; enabling it via netsh advfirewall set allprofiles logging droppedconnections/allowedconnections enable; and the log folder sometimes lacking the FullControl permission the mpssvc service needs, in which case the log file is never created and the folder must be created and the ACL granted manually. ↩ ↩2 ↩3 ↩4 ↩5
-
Microsoft Learn, Manage Windows Firewall with the command line. On configuring default behaviour, notifications (-NotifyOnListen False), and logging via Set-NetFirewallProfile; example program-rule creation with New-NetFirewallRule and removal via Remove-NetFirewallRule / netsh advfirewall firewall delete rule; the pattern of suppressing the error when a rule does not exist with -ErrorAction SilentlyContinue; an example query looking up rules by port condition via Get-NetFirewallPortFilter; and Set-NetFirewallProfile -Enabled False being the correct means of disabling a profile. ↩ ↩2 ↩3
-
Microsoft Learn, Use netsh advfirewall firewall context to control Windows Firewall behavior (KB947709). On the syntax of netsh advfirewall firewall add rule (name= / dir=in / action=allow / program= / enable=yes / remoteip= / profile= / protocol= / localport=) with examples of adding program and port rules; an example of removal via delete rule; the requirement to run from an elevated command prompt when a member of the Administrators group runs it in a UAC-enabled environment; and configuring logging via netsh advfirewall set currentprofile logging. ↩ ↩2 ↩3
-
Microsoft Learn, Audit Filtering Platform Packet Drop. On enabling the “Audit Filtering Platform Packet Drop” audit subcategory causing event 5152 (and 5153) to be logged whenever the Windows Filtering Platform drops a packet; and this subcategory’s very high event volume meaning Microsoft recommends using the per-connection event 5157 (Filtering Platform Connection) instead for monitoring blocked connections. ↩
Related Articles
Recent articles sharing the same tags. Deepen your understanding with closely related topics.
The Windows Certificate Store in Practice — User or Computer, Which Should You Use?
Should a client certificate go in the user store or the computer store? This practical guide works systematically through the classic cer...
Windows Security Audit Policy and Event Log Investigation in Practice — Becoming an IT Team That Can Read Event 4625
A practical guide for answering "please look into the failed sign-in logs." It covers the relationship between basic and advanced audit p...
A Practical Guide to Windows LAPS — Retiring the Shared Local Administrator Password Across All PCs
A shared local administrator password across every PC is fertile ground for Pass-the-Hash attacks, where the compromise of one machine sp...
SMB Signing and LDAP Channel Binding — Closing the "Other Half" of Your NTLM Defences in Practice
SMB signing and LDAP signing/channel binding are the defences that limit the damage from relay attacks while you work towards retiring NT...
Will NTLM Deprecation Stop Your Business Apps? — How to Collect Audit Logs, and the Order in Which to Kill Dependencies
A practical procedure for finding out where your Windows environment and business applications depend on NTLM ahead of its retirement: au...
Related Topics
These topic pages place the article in a broader service and decision context.
Windows Technical Topics
Topic hub for KomuraSoft LLC's Windows development, investigation, and legacy-asset articles.
Where This Topic Connects
This article connects naturally to the following service pages.
Windows App Development
We support Windows desktop applications that involve resident processing, device integration, operational logging, and maintainable structure.
Frequently Asked Questions
Common questions about the topic of this article.
- Does an app that only connects to a server as a client need a firewall rule at all?
- As a rule, no. The Windows Firewall's default is "block inbound, allow outbound", so a client app that only initiates connections outward communicates fine under the defaults. An inbound rule is only needed for the side that opens a port and waits for connections — in other words, server-type apps. There are two exceptions, though. In high-security environments the outbound default may have been changed to block as well, in which case you need to request an outbound rule too. And even a "client" app needs an inbound rule for any part of it that is itself designed to listen on a port to receive result notifications.
- Can't I just click "Allow access" on the "Windows Security Alert" dialog and be done with it?
- That gets you through the moment, but you cannot leave production operation to it. If a user with administrator rights cancels this dialog, a block rule is created. Worse, if the user has no administrator rights, a block rule is created no matter which button is pressed. Once a rule has been created, the dialog never appears again unless that rule is deleted, and communication keeps failing. In business apps where an ordinary end user is the one operating the machine on site, it is trivially easy to end up in a state where "someone cancelled it once, and now it never connects again". Microsoft itself recommends placing the rule before the app's first launch, precisely to avoid this.
- Should an inbound rule be built around the port or around the program?
- The basic approach is to combine them rather than use either alone. Program-based rules can pin down the target by the exe's full path, but if an update changes that path the rule loses track of its target (wildcards are not supported). Port-based rules make the request to IT unambiguous, but they also let through any other process that happens to listen on the same port. For a production business app, the minimal-privilege pattern is to build the rule around program + protocol + port, restrict the profile to Domain/Private, and restrict the remote IP to the client's subnet. Use a program-only rule only when the port is dynamic.
- The rule my installer registered doesn't seem to be taking effect on the client's PC. Why?
- It is likely that the client's firewall is centrally managed through GPO or Intune, and "local rule merging" (AllowLocalPolicyMerge) has been disabled. When that setting is disabled, a rule created locally exists in the profile but is not applied — rules can only be distributed centrally via GPO/CSP. Check the full set of active rules with Get-NetFirewallRule -PolicyStore ActiveStore, and ask the IT department to distribute the rule. Requests go through in one pass if you hand over the rule name, direction, program path, protocol and port, remote IP range, and profile all together.
- Is it fine to temporarily disable the firewall for triage purposes?
- Absolutely avoid disabling it by stopping the service (MpsSvc). That operation is unsupported by Microsoft and causes OS-level problems such as the Start menu stopping working or Store app updates failing. If you really need to disable it for triage, the correct method is to leave the service running and disable the profile with Set-NetFirewallProfile -Enabled False. Even so, restrict this to a few minutes of confirming whether the firewall is the cause, and restore it immediately once you have your answer. Leaving it disabled trades the PC's entire defence for a problem that a single added rule would have solved.