保留子网范围内的私有 IP 地址

Private IP address in reserved subnet range

我有一个 arm 模板,它有一个带有 2 个子网的 vNet。我正在尝试使用静态私有 IP 地址将 Nic 部署到其中一个。它曾经是动态的,并且运行良好。现在它是静态的,我已经设置了我希望网卡拥有的 IP,但是当我部署时,它说 IP 无效。我尝试更改我设置的IP,但仍然无效...

从我的模板中摘录:(subnetPart 是一个参数化数字,因为我们有几个 vnet 将被连接,但子网需要不冲突)

variables
"virtualNetworkRange": "[concat('10.', parameters('subnetPart'), '.10.0/26')]",
"ssrsSubnetRange": "[concat('10.', parameters('subnetPart'), '.10.8/29')]",
"ssrsPrivateIP": "[concat('10.', parameters('subnetPart'), '.10.10')]",

resources
{
  "name": "[variables('ExternalServicesVNET')]",
  "type": "Microsoft.Network/virtualNetworks",
  "location": "[resourceGroup().location]",
  "apiVersion": "2015-05-01-preview",
  "properties": {
    "addressSpace": {
      "addressPrefixes": [
        "[variables('virtualNetworkRange')]"
      ]
    },
    "subnets": [
      {
        "name": "[variables('jumpSubnetName')]",
        "properties": {
          "addressPrefix": "[variables('jumpSubnetRange')]"
        }

      },
      {
        "name": "[variables('ssrsSubnetName')]",
        "properties": {
          "addressPrefix": "[variables('ssrsSubnetRange')]"
        }

      }
    ]
  }
},
{
  "name": "[variables('SSRSvmNicName')]",
  "type": "Microsoft.Network/networkInterfaces",
  "location": "[resourceGroup().location]",
  "apiVersion": "2015-06-15",
  "dependsOn": [
    "[concat('Microsoft.Network/virtualNetworks/', variables('ExternalServicesVNET'))]"
  ],
  "tags": {
    "displayName": "SSRSvmNic"
  },
  "properties": {
    "ipConfigurations": [
      {
        "name": "ipconfig1",
        "properties": {
          "privateIPAllocationMethod": "Static",
          "privateIPAddress": "[variables('ssrsPrivateIP')]",
          "subnet": {
            "id": "[variables('ssrsSubnetRef')]"
          },
          "networkSecurityGroup": {
            "id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))]"
          }
        }
      }
    ]
  }
}

错误信息如下:

Resource Microsoft.Network/networkInterfaces 'hub2e40SsrsNic' failed with message '{
"error": {
 "code": "PrivateIPAddressInReservedRange",
 "message": "Private static IP address 10.100.10.10 falls within reserved IP range of subnet prefix 10.100.10.8/29.",

嗯好的,因为这些地址是保留的,所以它不能在子网范围内?好的,我将 IP 的最后一位更改为子网范围之外的 16。

Resource Microsoft.Network/networkInterfaces 'hub2e40SsrsNic' failed with message '{
  "error": {
    "code": "PrivateIPAddressNotInSubnet",
    "message": "Private static IP address 10.100.10.16 does not belong to the range of subnet prefix 10.100.10.8/29."

所以这也行不通...

有什么想法吗?非常感谢!

Azure 从每个子网中保留几个 IP 用于路由目的:

是的。 Azure 在每个子网中保留一些 IP 地址。子网的第一个和最后一个 IP 地址保留用于协议一致性,以及用于 Azure 服务的另外 3 个地址。

参考:https://docs.microsoft.com/en-us/azure/virtual-network/virtual-networks-faq

所以您在分配 IP 时需要考虑到这一点。因此,在您的情况下,您有 10.100.8-15,减去保留的 ips - 10.100.11-14。