Security recommendations / best practices for subnets, vnets, and Network Security Groups?
Looking for recommendations and where possible references to recommendations by Microsoft and/or other authoritative sources. I've gone through every bit of documentation I could find on the subject, and as best as I can tell this is a personal preference thing. I'm trying not to limit myself by shoehorning things into a traditional on-prem network design, but I'll start with that for a frame of reference.
So given a single vnet 10.10.0.0/16 with the following subnets:
- 10.10.1.0/24 - Management
- 10.10.2.0/24 - Web / Frontend
- 10.10.3.0/24 - Web / API
- 10.10.4.0/24 - Database
When I fire up VM's in those subnets I want to implement a fairly straightforward setup (this won't be an exhaustive list, just laying the groundwork to talk about NSG placement):
- Allow remote desktop from the management subnet to the other three subnets (Assume VPN connection to a jump box to kick off my RDP session, out of scope for this question though)
- Allow 80/443 from the public Internet to servers on the web/frontend segment
- Allow 80/443 from the web/frontend servers to the web/api subnet
- Allow 1433 from the web/api subnet to the database subnet
Given those requirements, I have a couple options with respect to filtering traffic. One is to define a single Network Security Group, and put those permits along with a deny any into its rulebase. I can then apply that one NSG to each of the subnets and I'm done. This is the old school approach more or less, kind alike defining ACL's on a layer 3 switch. It's the approach I'd take left up to my own devices, at least initially.
I could take a similar approach, but instead of the subnet I could apply the NSG to the network interfaces of the individual VM's. And I guess that doesn't hurt; now if one VM on a subnet gets compromised its neighbors aren't soft targets. Of course, if an attacker knocks over one of my SQL servers then chances are they're going to hit the others that have the same version and patch level. Still it's a nominal improvement with minimal overhead on my part so why not, so long as I'm positive no one will create a VM on a subnet and not apply the NSG. (I could put the NSG on both the subnet and the NIC, but I'm assuming there's at least a minor performance hit there.)
But for subnet-to-subnet communication I also have the option of defining multiple NSG's - one for each subnet - that just have simple rulebases. They go something like 1) allow RDP from the management subnet, 2) allow the individual ports needed for the type of VM on that subnet, and 3) deny any.
That last approach yields many simple rulebases, whereas the first two yield one (relatively) big one that's applied in multiple places. And of course there's a fourth option which is to apply an NSG for database servers to the network interfaces on the database VM's, and one for web servers to the web VM's, you get the idea.
So TLDR: Is one of those approaches better from a performance point of view, or from an audit/regulatory compliance standpoint? I'm assuming any of the above *can* work, just looking for input on what actually works and produces the best results. Thanks!
Posted Apr 14, 2020, 8:46 PM UTC
I prefer a mix of your options 2 and 3.
And NSG on each subnet to control traffic to that subnet, then an NSG on the NIC if it needs to be more restrictive than its partners in the subnet.
The problem with having one big ruleset used everywhere is that it can get challenging to manage, as you could break something unrelated by having a rule earlier that matches.
Thanks for the input! Striking that balance of complexity vs manageability is primarily what I'm going after. I used to manage rulebases with 500+ rules years ago, but that was with Checkpoint and an interface that actually lent itself to doing so... which this ain't. Thanks again!