配额和限制

本文档列出了适用于 Cloud NAT 的quotasquotas。如需详细了解配额,请参阅 Virtual Private Cloud 配额

给定的配额或限制按资源计算。配额和限制可能按项目、网络、区域或其他资源来设置。NAT IP 地址无法在 NAT 网关之间共享。如需更改配额,请参阅申请额外的配额

配额用于限制您的 Google Cloud 项目可使用的共享 Google Cloud 资源(包括硬件、软件和网络组件)的数量。因此,有以下功能的系统具有配额:

  • 监控 Google Cloud 产品和服务的使用情况或消耗情况。
  • 出于某些原因限制这些资源的消耗量,包括确保公平性和减少使用量高峰。
  • 维护可自动强制执行规定限制的配置。
  • 提供请求或更改配额的方法。

在大多数情况下,当超过配额时,系统会立即阻止对相关 Google 资源的访问,并且您尝试执行的任务将失败。在大多数情况下,配额适用于每个 Google Cloud 项目,并由使用该 Google Cloud 项目的所有应用和 IP 地址共享。

Cloud NAT 资源也有限制。这些限制与配额系统无关。除非另有说明,否则无法更改限制。

配额

如需了解影响 Cloud NAT 的配额,请参阅 Cloud Router quotas页面。

限制

错误 限额 Notes
NAT 网关数 每个 Cloud Router 路由器 50 个 每个网络支持每个区域最多 5 个 Cloud Router 实例,因此每个虚拟私有云 (VPC) 网络每个区域最多可以有 250 个 Cloud NAT 网关。如需了解 Cloud Router 配额,请参阅 Cloud Router 文档
每个网关的 NAT IP 地址

300 个人工输入的地址

300 个自动分配的地址

每个 NAT 网关可以拥有的外部 IP 地址的数量上限。但是,此值取决于静态 IP 地址在用 IP 地址 VPC 每个项目配额。
子网范围 每个网关 50 个

配置自定义子网范围列表时,可与网关关联的子网数上限。子网范围的数量可能超过该限值,因为每个子网可以具有一个主要 IPv4 范围以及一个或多个次要范围。

如果您为所有子网的主要范围或所有子网的主要范围和次要范围配置了 NAT,则此限制不适用。

NAT 规则 每个网关 50 个 如果超出此限制,API 将返回错误。
每条 NAT 规则的活跃 IP 地址数 300
Private NAT 子网 每个网关 50 个 可预留用作 Private NAT 来源 NAT 范围的子网数上限。这些子网的用途为 PRIVATE_NAT
每条规则的 CEL 表达式中的字符 2048
每个 Cloud Router 路由器实例的 CEL 表达式中的字符 50 万

限制

  • 一些服务器(例如旧式 DNS 服务器)要求从 64000 个 UDP 端口中随机选择端口,以增强安全性。由于 Cloud NAT 会从 64(或用户配置的数量)个端口中随机选择一个,因此最好为此类服务器分配一个外部 IP 地址,而不是使用 Cloud NAT。这是因为 Cloud NAT 不允许从外部发起连接,因此即使不考虑这一点,大多数此类服务器原本也需要使用一个外部 IP 地址。

  • Cloud NAT 不适用于旧式网络。

  • 不支持 NAT ALG(应用层网关)功能。这意味着 Cloud NAT 会更新包数据中的 IP(例如,对于 FTP、SIP 及其他此类协议)。

  • Cloud NAT 网关会为提供 NAT 服务的每个虚拟机网络接口实现 NAT 连接跟踪表。每个连接跟踪表中的条目是网关支持的协议的 5 元组哈希。

    只要相关的 NAT 超时时间,每个连接跟踪表中的条目就会持续存在。如需详细了解 NAT 超时,请参阅 NAT 超时

    对于与虚拟机的网络接口关联的所有 NAT 连接,连接跟踪表条目的数量上限为 65535。此上限汇总了网关支持的所有协议的连接数。

  • 设置较短的空闲连接超时值可能不起作用。

    系统会每 30 秒检查一次 NAT 映射是否存在过期和配置更改情况,因此,即使使用 5 秒钟的连接超时值,连接也可能会在长达 30 秒的时间内不可用(这属于最坏的情况,平均时长为 15 秒)。

Manage quotas

Cloud NAT enforces quotas on resource usage for various reasons. For example, quotas protect the community of Google Cloud users by preventing unforeseen spikes in usage. Quotas also help users who are exploring Google Cloud with the free tier to stay within their trial.

All projects start with the same quotas, which you can change by requesting additional quota. Some quotas might increase automatically based on your use of a product.

Permissions

To view quotas or request quota increases, Identity and Access Management (IAM) principals need one of the following roles.

Task Required role
Check quotas for a project One of the following:
Modify quotas, request additional quota One of the following:
  • Project Owner (roles/owner)
  • Project Editor (roles/editor)
  • Quota Administrator (roles/servicemanagement.quotaAdmin)
  • A custom role with the serviceusage.quotas.update permission

Check your quota

Console

  1. In the Google Cloud console, go to the Quotas page.

    Go to Quotas

  2. To search for the quota that you want to update, use the Filter table. If you don't know the name of the quota, use the links on this page instead.

gcloud

Using the Google Cloud CLI, run the following command to check your quotas. Replace PROJECT_ID with your own project ID.

      gcloud compute project-info describe --project PROJECT_ID

To check your used quota in a region, run the following command:

    gcloud compute regions describe example-region
    

Errors when exceeding your quota

If you exceed a quota with a gcloud command, gcloud outputs a quota exceeded error message and returns with the exit code 1.

If you exceed a quota with an API request, Google Cloud returns the following HTTP status code: 413 Request Entity Too Large.

Request additional quota

To increase or decrease most quotas, use the Google Cloud console. For more information, see Request a higher quota.

Console

  1. In the Google Cloud console, go to the Quotas page.

    Go to Quotas

  2. On the Quotas page, select the quotas that you want to change.
  3. At the top of the page, click Edit quotas.
  4. For Name, enter your name.
  5. Optional: For Phone, enter a phone number.
  6. Submit your request. Quota requests take 24 to 48 hours to process.

Resource availability

Each quota represents a maximum number for a particular type of resource that you can create, if that resource is available. It's important to note that quotas don't guarantee resource availability. Even if you have available quota, you can't create a new resource if it is not available.

For example, you might have sufficient quota to create a new regional, external IP address in the us-central1 region. However, that is not possible if there are no available external IP addresses in that region. Zonal resource availability can also affect your ability to create a new resource.

Situations where resources are unavailable in an entire region are rare. However, resources within a zone can be depleted from time to time, typically without impact to the service level agreement (SLA) for the type of resource. For more information, review the relevant SLA for the resource.