Launch price: every exam for $29.99 a year, for the first 300 buyers. See the price

CertStreak
Menu

Associate a NSG to a subnet or network interface

A worked example

Single answer

VM1 is in Subnet1 of a virtual network named VNet1. NSG-A is associated with Subnet1, and NSG-B is associated with the network interface of VM1. The custom rules are shown in the exhibit; no other custom rules exist in either NSG.

VM1 initiates an outbound HTTPS connection (TCP 443) to a public website.

NSGAssociated withDirectionPriorityDestinationPortProtocolAccess
NSG-ASubnet1Outbound200Internet443TCPDeny
NSG-BVM1 network interfaceOutbound200Internet443TCPAllow

Which NSG does Azure evaluate first for this connection, and is the connection ultimately allowed or blocked?

Choose one answer
Why

When an NSG is associated with both a subnet and a network interface in that subnet, Azure evaluates both and the traffic must be allowed by each. For outbound traffic the order is the reverse of inbound: the NIC-associated NSG is processed first, then the subnet-associated NSG. NSG-B allows the HTTPS flow, but NSG-A on Subnet1 then denies it, so the connection is blocked.

  • Correct: NSG-B first; NSG-A blocks the connection. For outbound traffic the NIC NSG (NSG-B) is evaluated before the subnet NSG (NSG-A), and traffic must pass both; NSG-B allows it but NSG-A denies it, so it is blocked.
  • Not correct: NSG-A first; NSG-B allows the connection. Both parts are wrong: outbound traffic is evaluated at the NIC NSG first, and NSG-A's deny rule blocks the flow because traffic must pass both NSGs.
  • Not correct: NSG-B first; NSG-B allows the connection. The order is right, but an allow in the NIC NSG is not enough; when NSGs are associated with both the NIC and the subnet, the traffic must pass both, and NSG-A denies it.
  • Not correct: NSG-A first; NSG-A blocks the connection. The outcome is right but the order is wrong: subnet-first evaluation applies to inbound traffic, while outbound traffic is evaluated at the network interface first.

Practise this topic until it's automatic.

Ten questions a day, every answer explained, and misses that come back until you beat them.

Start free