部署vNet的ARM模板失败

时间:2020-02-28 20:37:50

标签: azure azure-virtual-network

我正在使用此Arm模板部署vnet和3个子网,但我不断收到错误消息,无法完全解决问题所在。我需要将vnet分成三个子网。

Arm模板为:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "vnetName": {
      "value": "vnet-west-europe"
    },
    "vnetAddressPrefix": {
      "value": "10.1.254.0/24"
    },
    "subnet1Prefix": {
      "value": "10.1.254.0/27"
    },
    "subnet1Name": {
      "value": "subnet1-west-europe"
    },
    "subnet2Prefix": {
      "value": "10.1.254.96/25"
    },
    "subnet2Name": {
      "value": "subnet3-west-europe"
    },
    "location": {
      "value": "west europe"
    },
    "subnet3Prefix": {
      "value": "10.1.254.32/26"
    },
    "subnet3Name": {
      "value": "subnet3-west-europe"
    }
  }
}

我得到的错误是

New-AzResourceGroupDeployment : 20:28:18 - Error: Code=InvalidCIDRNotation; Message=The address prefix 10.1.254.96/25 in resource /subscriptions/<SUB-ID>/resourceGroups/network-rg/providers/Microsoft.Network/virtualNetworks/vnet-west-europe/subnets/subnet-west-europe has an invalid CIDR notation. For the given prefix length, the address prefix should be 10.1.254.0/25.
At line:1 char:1

但是,如果我将其更改为指定的IP,它将与子网1重叠

帮助:)

1 个答案:

答案 0 :(得分:1)

您在subnet2Prefix中的CIDR不正确:10.1.254.96/25

如果要那么长,则必须为10.1.254.0/2510.1.254.128/25

更改布局将为您提供帮助,从最大的子网开始,或者您可以使用更大的地址前缀并将其放在不同的C块上。

vnetAddressPrefix: 10.1.254.0/24
subnet1Prefix: 10.1.254.0/25
subnet2Prefix: 10.1.254.128/26
subnet3Prefix:10.1.254.192/27

使用此IP计算器来验证您的前缀:http://jodies.de/ipcalc?host=10.1.254.128&mask1=25&mask2=