Admin Power Level: Intermediate Chapter 13: Control Who Gets In and Out
Firewall profiles, rules, and connection profiles
A profile is a set of firewall settings for a network type: Domain, Private, or Public. A rule allows or blocks traffic for a program or port. A connection profile says which profile an adapter currently uses.
Lesson 1 of 2 in Chapter 13: Control Who Gets In and Out. Previous step in this path: Create a scheduled task. 3 learning objectives, 7 examples, and a knowledge check.
Start: what you will learn
A profile is a set of firewall settings for a network type: Domain, Private, or Public. A rule allows or blocks traffic for a program or port. A connection profile says which profile an adapter currently uses.
Learning objectives
- Explain Domain, Private, and Public profiles
- List firewall rules and filter them
- Read the connection profile of an adapter
Concept in simple words
What it is: a firewall is a guard that checks network traffic going into your computer and traffic going out of your computer. It does not check every file on your disk. It checks network packets, which are small pieces of data sent over a network. For each packet, the firewall asks a simple question: is there a rule that allows this traffic, or should the default action apply. A profile is a set of firewall settings for one kind of network. A rule is one allow or block decision. A connection profile tells you which profile one network adapter is using right now.
Why it works
Why it exists, and what problem it solves: a computer on a network is reachable. Programs on your computer may listen for connections, and other computers may try to reach them. Without a firewall, every listening program could be reachable from every network you join. That is risky on a network you do not trust. With a firewall, you start closed by default for incoming traffic, and then you open only the small holes you really need. That is the core problem this chapter solves: how to stay reachable for the right traffic, and closed for everything else.
What a profile really is: think of a profile as one complete settings page for one trust level. It says whether the firewall is on for that trust level, what happens to incoming traffic when no rule matches, and what happens to outgoing traffic when no rule matches. Windows has three profiles: Domain, Private, and Public. Only one profile is live for one network connection at one time. A different adapter, for example a wired adapter and a wireless adapter, can be on different profiles at the same time, so always check each adapter you care about.
Domain, in depth: the Domain profile applies when your computer is joined to a managed domain and it has proved its identity to that domain. In plain words, this is a managed work network where an administrator sets the rules. You do not pick this profile by hand for fun. Windows sets the matching connection category, called DomainAuthenticated, when domain authentication succeeds. If you see DomainAuthenticated in a connection profile, that is the domain case, and it maps to the Domain firewall profile. The name is different, but the idea is the same: a trusted, managed network.
Private, in depth: the Private profile applies to a network you trust, such as your home network or a small trusted work network. Trust here means you know the network and the devices on it, and you may want sharing and discovery to work. Discovery means your computer can see other devices, and other devices can see your computer, when sharing is set up. Private is more open than Public, but it is not open to everything. Incoming traffic still needs an allow rule, unless the profile default on your machine says otherwise. Private means trusted, not unprotected.
Public, in depth: the Public profile applies to a network you do not trust, such as a cafe, an airport, a hotel, or any network where strangers share the connection with you. On Public, your computer is hidden from other devices as much as possible, and sharing and discovery are off by default. Public is normally the strictest profile, because the risk is highest. Strict does not mean you have no internet. Outgoing traffic, such as your web browser asking a website for a page, is usually allowed by the outbound default. Public mainly blocks unsolicited incoming traffic, which is traffic nobody on your computer asked for.
How Windows picks the live profile: Windows assigns a category to each network connection. That category is stored in the connection profile for that adapter. When you move a laptop from a trusted network to an untrusted network, the live category can change, and the firewall profile in force changes with it. That is why you must never guess the profile from where you think you are. Check the adapter. A rule that allows traffic on Private does nothing for you when the same adapter is now on Public, and that mismatch explains many sudden connection failures.
Default actions, in depth: DefaultInboundAction is what happens to incoming traffic when no rule matches. DefaultOutboundAction is what happens to outgoing traffic when no rule matches. A common setup is Block for inbound and Allow for outbound. That means unsolicited incoming traffic is blocked unless a rule allows it, while outgoing traffic is allowed unless a rule blocks it. Read your own output before you assume this setup, because a managed machine can show NotConfigured, which means the setting comes from policy rather than from a simple local value. Your job is to read what your machine actually shows, not to memorise one pair of values for every machine.
Rule anatomy, part one, identity: every rule has a Name and a DisplayName. Name is the technical name. It is often long, it can look like a code, and it is the safest key for changing a rule later. DisplayName is the readable name you see in lists, such as Allow lab web. DisplayName can repeat, because two rules can share a readable name, while Name is meant to identify one rule. A rule can also have a Description, which is a short note about why the rule exists, and a DisplayGroup, which groups related rules from one feature together. When you read a rule, read Name and DisplayName together, never Name alone.
Rule anatomy, part two, decision fields: Enabled tells you whether the rule is live right now. A disabled rule exists, but it does nothing. Direction tells you whether the rule checks traffic coming in, which is Inbound, or traffic going out, which is Outbound. Action tells you what happens when traffic matches: Allow or Block. Profile tells you which firewall profiles the rule applies to: Domain, Private, Public, or Any, where Any means all three. A rule is only useful when all four fields line up with your need. An enabled Allow rule for Outbound traffic will never fix an Inbound problem.
Rule anatomy, part three, filters: the main rule object does not carry the port, the program, or the address in its short list view. Those details live in linked filter objects that Windows creates with each rule. That is why Get-NetFirewallRule alone does not show a LocalPort column. To see the port and protocol for one rule, pipe that rule to Get-NetFirewallPortFilter. To see the program for one rule, use the application filter in the same way. Do not be surprised when the first list looks short on detail. The detail is one step further down, and that step is part of reading a rule properly.
How matching works, in simple terms: think of a rule as a checklist. For traffic to match the rule, it must fit the direction, the profile, and every narrow condition you set, such as one port, one program, or one address range. A rule with no port limit fits more traffic than a rule with one port. A rule with Profile set to Any fits more networks than a rule with Profile set to Private. Narrowing a rule means adding conditions to that checklist, so fewer packets can pass it. Widening a rule means removing conditions, so more packets can pass it. Every change you make in the next lesson is a change to this checklist.
How it works, step by step
How it works, step by step: First, list the profiles with Get-NetFirewallProfile and note which ones are enabled and what their default inbound and outbound actions are. Second, check the connection profile of each adapter with Get-NetConnectionProfile, so you know which profile is actually live for the adapter you care about. Third, list the rules with Get-NetFirewallRule, and filter early, because a normal machine has hundreds of rules. Fourth, read DisplayName as well as Name, and read Enabled, Direction, Action, and Profile together. Fifth, when you need the port or program, follow the rule to its filter object. Sixth, only then decide whether a change is needed, and note the current values before you change anything.
Let us walk through the profile example, piece by piece: Get-NetFirewallProfile returns one object per profile. The pipe sends those objects to Select-Object. Select-Object keeps only the properties you name, so the output stays readable. Name tells you which profile the row is about. Enabled tells you whether the firewall is on for that profile. DefaultInboundAction tells you what happens to incoming traffic when no rule matches. In the illustrative output, Domain and Public both show Enabled as True and DefaultInboundAction as Block. That means the firewall is on for those profiles, and incoming traffic with no matching allow rule is blocked. Look for the row that matches your live profile, not just any row that looks good.
Let us walk through the connection example, piece by piece: Get-NetConnectionProfile returns one object per network adapter connection. Select-Object keeps InterfaceAlias and NetworkCategory. InterfaceAlias is the name of the adapter, such as Ethernet or Wi-Fi. NetworkCategory is the trust category for that connection: Private, Public, or DomainAuthenticated. In the illustrative output, Ethernet shows Private. That means the Private firewall profile is the live profile for that adapter. If the same adapter later shows Public, then only rules that apply to Public, or to Any, can affect traffic on that adapter.
Let us walk through the filtered rules example, piece by piece: Get-NetFirewallRule lists the rules. Where-Object filters them, one object at a time. Inside the filter, $_ means the current rule. $_.Enabled -eq "True" keeps only rules that are enabled. -and joins two tests, so the second test must also pass. $_.Direction -eq "Inbound" keeps only incoming rules. Select-Object then shows DisplayName, Direction, and Action, and -First 3 keeps only the first three rows for reading. In the illustrative output, Allow lab web is an Inbound Allow rule. If you change -First 3 to a larger number, you see more rules. If you remove -First 3, you may see hundreds of rows, which is why filtering and limiting the list matters.
Let us walk through the port filter example, piece by piece: Get-NetFirewallRule finds one rule, and the pipe sends that rule object to Get-NetFirewallPortFilter. That cmdlet returns the port filter linked to the rule. Select-Object then shows Protocol and LocalPort. Protocol tells you the kind of traffic, such as TCP or UDP. LocalPort tells you the port on your own computer that the rule is about. In the illustrative output, the protocol is TCP and the local port is 8080. If this step shows nothing, check that you used the right rule name, because a wrong name gives you no rule to follow to its filter.
What to look for in the output, and what empty output means: look for the live profile first, then the matching rule, then the four decision fields together. If a command returns no rows, that is information, not proof that the firewall is off. It usually means no rule matched your filter, or you typed a name that does not exist, or you filtered too narrowly. Loosen one filter at a time, check the spelling of the name, and list a few rules without the filter to see what names really exist. Never jump from empty output to a wide allow rule. Empty output tells you to look more carefully, not to open more doors.
When to use it
When to use these commands, and when not to change anything yet: use these read only commands whenever traffic behaves in a surprising way, before you change any rule, and after any network change, such as moving to a new network or plugging in a new adapter. Do not guess a profile from where you think you are, check the adapter profile, because a laptop that moved from work to a cafe may now be on Public. Do not change rules just to make a problem go away without reading the rule first, because a wide allow rule can stay open long after you forget about it. Work only on your own computer and in your own lab, and note the current rule values before any change, so you can put them back.
A short check you can do in your head: ask four questions about any rule. Is it enabled. Is the direction the one I need. Is the action the one I want. Does the profile include the network I am actually on. If any answer is no, you have found your mismatch. If all four answers are yes, then check the filter: the port, the program, or the address. Most firewall mysteries in this chapter are one of those five checks, not a deep network fault. That habit will save you more time than any single command.
Worked examples
Read each example in order. Each one explains its parts, then shows what to look for in the output.
Syntax
Get-NetFirewallProfile | Get-NetFirewallRule | Get-NetConnectionProfileExample 1
Shows each profile, whether its firewall is on, and what happens to inbound traffic by default. Get-NetFirewallProfile returns one object per profile, and Select-Object keeps only Name, Enabled, and DefaultInboundAction, so the list stays readable.
Get-NetFirewallProfile | Select-Object Name, Enabled, DefaultInboundActionIllustrative output: Name Enabled DefaultInboundAction ---- ------- -------------------- Domain True Block Public True Block
Example 2
Reads one profile only. -Name Private limits the result to the Private profile, so you can check its inbound and outbound defaults without reading all three rows. Use -Name Domain or -Name Public in the same way for the other profiles.
Get-NetFirewallProfile -Name Private | Select-Object Name, Enabled, DefaultInboundAction, DefaultOutboundActionIllustrative output: Name Enabled DefaultInboundAction DefaultOutboundAction ---- ------- -------------------- --------------------- Private True Block Allow
Example 3
Shows which profile each adapter currently uses, so you can match rules to reality. InterfaceAlias is the adapter name, and NetworkCategory is Private, Public, or DomainAuthenticated. DomainAuthenticated maps to the Domain firewall profile.
Get-NetConnectionProfile | Select-Object InterfaceAlias, NetworkCategoryIllustrative output: InterfaceAlias NetworkCategory -------------- --------------- Ethernet Private
Example 4
Reads the connection profile for one adapter only. -InterfaceAlias Ethernet limits the result to that adapter, which helps when a machine has several adapters and you only care about one of them. Replace Ethernet with your own adapter name from the full list.
Get-NetConnectionProfile -InterfaceAlias Ethernet | Select-Object Name, InterfaceAlias, NetworkCategoryIllustrative output: Name InterfaceAlias NetworkCategory ---- -------------- --------------- Ethernet Ethernet Private
Example 5
Get-NetFirewallRule lists the rules. Where-Object keeps only rules where Enabled equals True and Direction equals Inbound, so you see live incoming rules only. $_ means the current rule in the filter. Select-Object shows the readable DisplayName, the Direction, and the Action, and -First 3 keeps the list short for reading.
Get-NetFirewallRule | Where-Object { $_.Enabled -eq "True" -and $_.Direction -eq "Inbound" } | Select-Object DisplayName, Direction, Action -First 3Illustrative output: DisplayName Direction Action ----------- --------- ------ Allow lab web Inbound Allow
Example 6
Filters with cmdlet parameters instead of Where-Object. -Enabled True, -Direction Inbound, and -Action Allow are all direct filters on Get-NetFirewallRule, so the result is live incoming allow rules only. Adding Profile to the output shows whether each rule applies to Domain, Private, Public, or Any.
Get-NetFirewallRule -Enabled True -Direction Inbound -Action Allow | Select-Object DisplayName, Profile, Enabled -First 5Illustrative output: DisplayName Profile Action ----------- ------- ------ Allow lab web Private Allow
Example 7
Follows one rule to its port filter. Get-NetFirewallRule finds the rule by its readable name, the pipe sends it to Get-NetFirewallPortFilter, and Select-Object shows Protocol and LocalPort. This is the step that reveals the port, because the main rule list does not show ports. If you see nothing here, check the rule name first.
Get-NetFirewallRule -DisplayName "Allow lab web" | Get-NetFirewallPortFilter | Select-Object Protocol, LocalPortIllustrative output: Protocol LocalPort -------- --------- TCP 8080
Nothing on this page executes PowerShell code. The outputs above are illustrative only.
Common mistakes and troubleshooting
Read these before you try the examples, so you can spot the same problems in your own work.
- Assuming a rule applies everywhere, when it only applies to one profile.
- Reading only rule names, which are technical. Read DisplayName and the profile list too.
- Seeing that a rule is enabled and assuming it allows your traffic, without checking its Direction, so you miss that it is an outbound rule when you needed an inbound one.
- Mixing up DomainAuthenticated and Domain. The connection profile says DomainAuthenticated, while the firewall profile is called Domain. They describe the same managed case, but the words are not identical.
- Thinking Public means no internet at all. Public mainly blocks unsolicited incoming traffic, while outgoing traffic is usually still allowed by the outbound default. Check DefaultOutboundAction on your machine.
- Reading only the first few rules and treating them as the full list. -First 3 is a reading aid, not a complete inventory. Remove the limit or widen the filter when you need the full picture.
- Checking only one adapter and missing the adapter that actually carries the traffic. A machine can have several adapters, each with its own connection profile, so list all adapters first.
- Seeing no rows and assuming the firewall is off. No rows usually means no rule matched your filter, or the name was typed wrong. Loosen one filter at a time and check the real names before you change anything.
Knowledge check
Knowledge check
Which profile is normally strictest?
Pick one answer. Feedback appears right away, and you can try again.
Remember this and next step
Remember this: the profile tells you how strict the network is, the rule tells you what is allowed or blocked, and the connection profile tells you which profile is live right now. Domain means managed, Private means trusted, Public means untrusted and normally strictest. A rule only helps when it is enabled, in the right direction, with the right action, on the right profile, and with a filter that matches your traffic. Check all of those, in that order, and a firewall mystery usually becomes a simple mismatch you can explain in plain words.
Next step: Create, modify, and enable firewall rules