What is a Network Security Group and how are its rules evaluated?
BeginnerConceptNetworking
Answer
An NSG is a stateful packet filter with priority-ordered rules (100–4096, lower first; first match wins). It attaches to a subnet, a NIC, or both. Each rule matches source, source port, destination, destination port, protocol, and allows or denies.
Default rules (priority 65000+) allow traffic within the VNet and from Azure Load Balancer inbound, deny all other inbound, and allow all outbound. Return traffic of an allowed flow is permitted automatically.
az network nsg rule create -g rg -n allow-https --nsg-name nsg-web --priority 100 \
--direction Inbound --access Allow --protocol Tcp \
--source-address-prefixes Internet --destination-port-ranges 443
More on Networking
What is a VNet and how does it compare to an AWS VPC?BeginnerHow many IP addresses does Azure reserve in each subnet?BeginnerIf an NSG is on both the subnet and the NIC, how is traffic evaluated?AdvancedWhat are service tags and why use them in NSG rules?BeginnerWhat is an Application Security Group (ASG)?IntermediateWhat are system routes and user-defined routes (UDRs)?Intermediate