Skip to content

Commit 893cb48

Browse files
authored
Merge pull request #295988 from mbender-ms/avnm-gap-docs
virtual network manager | New Docs | IPAM docs | enforce-vnet-create-azure-policy.md | GA
2 parents a3afa65 + f434eef commit 893cb48

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed

articles/virtual-network-manager/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
items:
2626
- name: Create a secured hub and spoke
2727
href: tutorial-create-secured-hub-and-spoke.md
28+
- name: Prevent overlapping IP address spaces with Azure Policy and IPAM
29+
href: Prevent-overlapping-ip-address-space-policy-ipam.md
2830
- name: Concepts
2931
items:
3032
- name: FAQ
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
---
2+
title: Prevent overlapping virtual network address spaces with Azure Policy and IPAM
3+
description: This article describes how to use Azure Policy and IPAM pools to prevent overlapping address spaces in Azure Virtual Network Manager.
4+
author: mbender-ms
5+
ms.author: mbender
6+
ms.service: azure-virtual-network-manager
7+
ms.topic: concept-article
8+
ms.date: 03/10/2025
9+
ms.custom: template-concept
10+
---
11+
12+
# Prevent overlapping virtual network address spaces with Azure Policy and IPAM
13+
14+
[!INCLUDE [virtual-network-manager-ipam](../../includes/virtual-network-manager-ipam.md)]
15+
16+
Azure Virtual Network Manager helps you centrally manage virtual networks across your organization. While it provides governance for VNets, it doesn't automatically prevent overlapping address spaces during virtual network creation or updates. You can enforce nonoverlapping address spaces by combining [Azure Policy](../governance/policy/overview.md) with [IP Address Management (IPAM) pools](concept-ip-address-management.md#manage-ip-address-pools), ensuring network connectivity without IP conflicts in your environment.
17+
18+
The following sample Azure policy definition ensures that any virtual network (`Microsoft.Network/virtualNetworks`) in the scope of this policy definition must have one IPAM pool prefix allocation from one of the two specified pools. If a virtual network lacks an allocation from either pool, the policy denies the creation or update of a virtual network by enforcing the use of nonoverlapped classless inter-domain routing (CIDRs) addresses.
19+
20+
```json
21+
{
22+
"mode": "All",
23+
24+
    "parameters": {},
25+
26+
    "policyRule": {
27+
28+
      "if": {
29+
30+
        "allOf": [
31+
32+
          {
33+
34+
            "field": "type",
35+
36+
            "equals": "Microsoft.Network/virtualNetworks"
37+
38+
          },
39+
40+
          {
41+
42+
            "not": {
43+
44+
              "anyOf": [
45+
46+
                {
47+
48+
                  "field": "Microsoft.Network/virtualnetworks/addressSpace.ipamPoolPrefixAllocations[*].pool.id",
49+
50+
                  "equals": "/subscriptions/<subscriptionID>/resourceGroups/<resourceGroupName>/providers/Microsoft.Network/networkManagers/network-manager/ipamPools/IPAM-pool-2"
51+
52+
                },
53+
54+
                {
55+
56+
                  "field": "Microsoft.Network/virtualnetworks/addressSpace.ipamPoolPrefixAllocations[*].pool.id",
57+
58+
                  "equals": "/subscriptions/subscriptionID/resourceGroups/<resourceGroupName>/providers/Microsoft.Network/networkManagers/network-manager/ipamPools/IPAM-pool-3"
59+
60+
                }
61+
62+
              ]
63+
64+
            }
65+
66+
          }
67+
68+
        ]
69+
70+
      },
71+
72+
      "then": {
73+
74+
        "effect": "deny"
75+
76+
      }
77+
78+
    }
79+
}
80+
81+
```
82+
83+
Included in the policy definition are the following actions:
84+
85+
- **Resource Check** - It applies only to virtual networks (`Microsoft.Network/virtualNetworks`).
86+
- **Pool Allocation Check** - It verifies if the virtual network has an IPAM pool allocation from either:
87+
- `IPAM-pool-2`, or
88+
- `IPAM-pool-3`.
89+
- **Enforcement** - If neither allocation is present, the policy denies the action. And in order to have pool allocation, IP prefixes must be nonoverlapped within the pool, as such no VNets with overlapped prefixes can be created.
90+
Resource Check: It applies only to virtual networks (`Microsoft.Network/virtualNetworks`).
91+
92+
## Implementation steps of the policy
93+
94+
With the policy definition, you can enforce nonoverlapping address spaces in your Azure environment. Follow these steps to implement the policy:
95+
96+
1. **Identify existing network manager and IPAM pools** - Ensure you have an existing Azure Virtual Network Manager instance and at least two IPAM pools created. For more information, see [Create a virtual network manager](./create-virtual-network-manager-powershell.md) and [Create an IPAM pool](./how-to-manage-ip-addresses-network-manager.md).
97+
1. **Create an Azure Policy definition** - Create a policy definition in Azure Policy using the JSON example. You can do this through the Azure portal, Azure CLI, or PowerShell. For more information, see [Create and assign a policy definition](../governance/policy/tutorials/create-and-manage.md).
98+
2. **Assign the policy** - Assign the policy to a specific scope (subscription or management group) where you want to enforce the nonoverlapping address space rule.
99+
1. **Test the policy** - Create or update a virtual network without an IPAM pool allocation from the specified pools. The operation should be denied if the policy is working correctly.
100+
101+
102+
## Next steps
103+
> [!div class="nextstepaction"]
104+
> [Manage IP addresses with Azure Virtual Network Manager](./how-to-manage-ip-addresses-network-manager.md)

0 commit comments

Comments
 (0)