What if your network could guard itself without you lifting a finger?
Why Network Security Groups (NSG) in Azure? - Purpose & Use Cases
Imagine you have a big office building with many rooms, and you want to control who can enter each room. Without a security guard or a system, you have to check every person manually at every door.
Manually checking each visitor at every door is slow, tiring, and easy to make mistakes. You might forget to check someone or let the wrong person in, causing security risks.
Network Security Groups act like smart security guards that automatically check and control who can enter or leave each room (network resource) based on clear rules. This keeps your network safe without constant manual work.
Open all ports and hope no one unwanted connectsCreate NSG rules to allow only trusted traffic on specific ports
With NSGs, you can easily protect your cloud network by defining simple rules that automatically block unwanted access and allow trusted connections.
For example, you can allow your web server to accept internet traffic only on ports 80 and 443, while blocking all other ports to keep hackers out.
Manual network control is slow and risky.
NSGs automate and simplify network security.
They help protect cloud resources by controlling traffic with rules.
Practice
Solution
Step 1: Understand NSG function
NSGs are designed to filter network traffic to and from Azure resources.Step 2: Identify correct purpose
They do not store data, manage identities, or monitor performance.Final Answer:
To control inbound and outbound traffic to Azure resources -> Option CQuick Check:
NSG controls traffic [OK]
- Confusing NSG with storage or identity services
- Thinking NSG monitors performance
- Assuming NSG stores data
Solution
Step 1: Understand NSG rule priority format
NSG rule priority is a unique integer between 100 and 4096 that determines rule evaluation order.Step 2: Eliminate incorrect types
Priority is not a string, boolean, or IP range.Final Answer:
Priority must be a unique integer between 100 and 4096 -> Option DQuick Check:
Priority = integer 100-4096 [OK]
- Using strings or booleans for priority
- Confusing priority with IP ranges
- Not using unique priority numbers
Priority: 200, Direction: Inbound, Access: Deny, Source: Any, Destination: 10.0.0.4, Protocol: TCP, Port: 22What happens when a user tries to SSH (port 22) to 10.0.0.4?
Solution
Step 1: Analyze rule details
The rule denies inbound TCP traffic on port 22 to destination 10.0.0.4 from any source.Step 2: Determine effect on SSH connection
SSH uses TCP port 22, so the connection attempt matches the deny rule and is blocked.Final Answer:
The connection is denied -> Option AQuick Check:
Deny inbound TCP port 22 = connection denied [OK]
- Assuming 'Any' source means allow
- Confusing deny with logging
- Ignoring direction and port in rule
Solution
Step 1: Check rule priority and conflicts
NSG rules are evaluated by priority; a deny rule with higher priority can block traffic despite allow rules.Step 2: Confirm rule attachment and protocol
While attachment and protocol matter, the most common cause is a conflicting higher priority deny rule.Final Answer:
A higher priority deny rule blocks port 80 traffic -> Option BQuick Check:
Higher priority deny overrides allow [OK]
- Ignoring rule priority order
- Assuming NSG attachment is always correct
- Confusing protocol types
Solution
Step 1: Allow only specific IP inbound on port 3389
Priority: 300, Direction: Inbound, Access: Allow, Source: 203.0.113.5, Destination: Any, Protocol: TCP, Port: 3389 allows inbound TCP traffic on port 3389 only from IP 203.0.113.5, which matches the requirement.Step 2: Check other options for correctness
Priority: 100, Direction: Inbound, Access: Deny, Source: Any, Destination: Any, Protocol: TCP, Port: 3389 denies all inbound TCP 3389 traffic, blocking access. Priority: 200, Direction: Inbound, Access: Allow, Source: Any, Destination: Any, Protocol: TCP, Port: 3389 allows all sources, which is insecure. Priority: 400, Direction: Outbound, Access: Allow, Source: 203.0.113.5, Destination: Any, Protocol: TCP, Port: 3389 is outbound, irrelevant for inbound access.Final Answer:
Priority: 300, Direction: Inbound, Access: Allow, Source: 203.0.113.5, Destination: Any, Protocol: TCP, Port: 3389 -> Option AQuick Check:
Allow inbound TCP 3389 from specific IP [OK]
- Allowing all sources instead of specific IP
- Using outbound direction instead of inbound
- Denying all traffic without exception
Ready to prove it?
Pass the test and this pattern moves unknown
