Evaluating Effective Security Rules with Network Watcher
This lesson explains the Network Watcher tools, and a method for troubleshooting connectivity.
Learning outcomes
After completing this lesson, you will be able to:
- Choose a diagnostic tool for a question.
- Follow a troubleshooting sequence.
- Distinguish filtering faults from routing faults.
- Explain the change from NSG to VNet flow logs.
Why diagnose rather than read
A single packet may pass security admin rules, a subnet NSG, a NIC NSG, a UDR and a firewall. A person who reads each rule set in turn can easily miss something. Azure Network Watcher provides tools that calculate the actual result. It is enabled automatically when a virtual network is created or updated, with one instance per region and subscription.
The tools fall into three groups: monitoring, such as Topology and Connection monitor; diagnostics, such as IP flow verify and Next hop; and traffic, such as flow logs and traffic analytics.
The diagnostic tools
Each tool answers a particular question. The following table gives a way of choosing.
| Tool | Question it answers | What you provide |
|---|---|---|
| IP flow verify | Is this flow allowed to or from a VM, and which rule decided? | VM, direction, protocol, local and remote address and port |
| NSG diagnostics | How does this traffic pass through each NSG on the path? | A source, destination and port, for a resource such as a VM or NIC |
| Effective security rules | Which rules apply to this NIC, once they are combined? | A network interface |
| Next hop | Where does this VM send this destination, and which route says so? | VM, source and destination address |
| Connection troubleshoot | Can this source reach this destination, and where does it stop? | A source VM and a destination |
| Packet capture | What is really on the wire? | A VM, with optional filters |
| VPN troubleshoot | Why is this gateway or tunnel failing? | A gateway or connection |
IP flow verify and NSG diagnostics are close relatives. IP flow verify tests a single VM's rules and returns one verdict and the rule name. NSG diagnostics gives more detail about rule evaluation on the whole path. Neither sends real traffic: they evaluate rules logically, so a pass does not prove that an application is listening.
Effective security rules lists the aggregated rules on a NIC. It answers the question of what applies, while IP flow verify answers the question of what happens to one flow. Effective rules are not displayed for a private endpoint's network interface.
Network Watcher tools
A troubleshooting method
A systematic approach prevents wasted effort. When a connection fails, work through the following steps.
-
Test the path
Run Connection troubleshoot to find where the failure occurs.
-
Check filtering
Run IP flow verify in the relevant direction, and note the rule.
-
Check routing
Run Next hop. A hop of None means that the traffic is dropped, and a virtual appliance hop means that a firewall is involved.
-
Check the firewall
If a firewall is the next hop, read its logs.
-
Check the workload
If all of these pass, look at the application and the guest firewall.
The following command runs IP flow verify from Azure Cloud Shell. It asks whether a VM may receive TCP traffic on port 3389 from an internet address.
az network watcher test-ip-flow --resource-group RG --vm VM --direction Inbound --protocol TCP \
--local 10.0.1.4:3389 --remote 203.0.113.10:50000Diagnosing a failed connection
Flow logs and traffic analytics
Diagnostic tools answer questions about a moment, and flow logs record what actually happened over time. They are invaluable for investigating an incident, as they show which addresses connected and whether traffic was allowed or denied.
VNet flow logs are the current option, and they record traffic at the virtual network level, including an indication of encryption and of decisions by security admin rules. NSG flow logs retire on 30 September 2027, and new ones can no longer be created. After retirement, their resources are deleted, although records already stored remain. Do not run both on the same workload, because that duplicates logging. VNet flow logs go to a Standard storage account, and a traffic analytics workspace can summarize them, showing top talkers, unusual flows and connections to malicious addresses.
Microsoft Sentinel can use these logs too, through a solution for Azure network data. Keep in mind that flow logs for traffic to private endpoints are limited, as NSG flow logs are unavailable for inbound traffic destined for a private endpoint.
Flow logs
Separating a filter fault from a routing fault
A VM in a spoke cannot reach a server on another spoke. IP flow verify shows that outbound traffic is allowed by an NSG rule. Next hop shows a next hop type of None. What is the problem, and what should you check?
IP flow verify shows that filtering is not the fault. A next hop of None means that Azure has no valid route, and the packets are dropped. Spokes that are peered to a hub do not reach each other by default, because peering is not transitive. Check the UDR on the subnet, which should send the destination range to the hub firewall as a virtual appliance, and check that the firewall's address is correct.
Changing NSG rules would not help, because they already allow the flow. Packet capture would show that traffic leaves nowhere, which adds little. Connection troubleshoot would confirm the failure, but it would not by itself correct the route.
IP flow verify shows Allow, but an application still cannot connect. What might be wrong?
Show answer
IP flow verify checks rules only. The route, the guest firewall or the application itself may be at fault.
Exam Tips
Remember for the exam
- IP flow verify gives a verdict and the rule that decided it.
- Next hop finds routing faults; a hop of None means that packets are dropped.
- Create VNet flow logs, as NSG flow logs retire on 30 September 2027.
- IP flow verify tests rules logically, so it does not prove that an application works.