Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Private NAT para os spokes do Network Connectivity Center
Com o Private NAT, é possível criar um gateway do Private NAT
que funciona em conjunto com os spokes do Network Connectivity Center
para executar a conversão de endereços de rede (NAT) entre as seguintes
redes:
Redes de nuvem privada virtual (VPC): nesse
cenário, as redes VPC que você quer conectar são anexadas
a um hub do Network Connectivity Center como spokes de VPC.
Redes VPC e redes fora de Google Cloud: nesse
cenário, uma ou mais redes VPC são anexadas a um
hub do Network Connectivity Center como spokes da VPC e conectadas às suas
redes locais ou de outros provedores de nuvem por spokes híbridos.
O Private NAT usa uma configuração
de NAT de type=PRIVATE para permitir que redes com intervalos de endereços IP de sub-rede
sobrepostos se comuniquem. No entanto, apenas sub-redes sem sobreposição podem se conectar
uma à outra.
Você precisa criar uma regra NAT personalizada referenciando um hub do Network Connectivity Center.
A regra NAT especifica um intervalo de endereços IP NAT de uma sub-rede de finalidade
PRIVATE_NAT que o Private NAT usa para executar NAT no tráfego
entre as redes conectadas.
Quando você cria uma instância de VM em um intervalo de sub-rede em que o
Private NAT
é aplicado, todo o tráfego de saída dessa instância de VM é traduzido pelo
gateway se o spoke de destino estiver no mesmo hub do Network Connectivity Center que
o gateway. O Private NAT converte o tráfego para
raios de destino na mesma região do
gateway do Private NAT e entre regiões.
Um gateway NAT particular é associado a intervalos de endereços IP de sub-rede
em uma única região em uma única rede VPC.
Isso significa que um gateway do Private NAT
criado em uma rede VPC não
oferece serviços de NAT para VMs em outros spokes do hub do Network Connectivity Center,
mesmo que as VMs estejam na mesma região do gateway.
Tráfego entre redes VPC
As especificações adicionais a seguir se aplicam ao tráfego entre
redes VPC (NAT inter-VPC):
Para ativar o Inter-VPC NAT entre duas redes
VPC, cada rede VPC precisa ser configurada como um
spoke VPC de um hub do Network Connectivity Center.
É preciso garantir que não haja intervalos de endereços IP sobrepostos nos spokes da VPC. Para mais informações, consulte Criar um spoke VPC.
O hub do Network Connectivity Center associado ao gateway do Private NAT
precisa ter pelo menos dois spokes de VPC, em que um deles
é a rede VPC do
gateway do Private NAT.
O Inter-VPC NAT é compatível com NAT entre spokes VPC do Network Connectivity Center, e não entre redes VPC conectadas usando o peering de rede VPC.
Tráfego entre redes VPC e outras redes
As especificações adicionais a seguir se aplicam ao tráfego entre
redes VPC e redes fora de Google Cloud:
A rede VPC de origem precisa ser configurada como um
spoke VPC de um hub do Network Connectivity Center.
Um spoke híbrido precisa ser anexado ao mesmo hub do Network Connectivity Center para
estabelecer a conectividade entre o spoke VPC e
a rede de destino fora de Google Cloud. Para mais informações,
consulte Como estabelecer conectividade entre spokes híbridos e spokes de VPC.
Para saber mais sobre os requisitos para usar spokes VPC e
híbridos no mesmo hub do Network Connectivity Center, consulte
Troca de rotas com spokes VPC.
Configuração básica e fluxo de trabalho
O diagrama a seguir mostra uma configuração básica de NAT privada
para o tráfego entre dois spokes da VPC:
Exemplo de conversão Inter-VPC NAT (clique para ampliar).
Neste exemplo, o Private NAT é configurado da seguinte maneira:
O gateway pvt-nat-gw está configurado em vpc-a para ser aplicado a todos os intervalos de endereços IP de subnet-a na região us-east1. Usando os intervalos de IP NAT de pvt-nat-gw, uma instância de máquina virtual (VM) em subnet-a de vpc-a pode enviar tráfego para uma VM em subnet-b de vpc-b, mesmo que subnet-a de vpc-a
se sobreponha a subnet-c de vpc-b.
vpc-a e vpc-b são configurados como spokes de um hub do Network Connectivity Center.
O gateway pvt-nat-gw está configurado para fornecer NAT entre redes VPC configuradas como spokes VPC no mesmo hub do Network Connectivity Center.
Exemplo de fluxo de trabalho
No diagrama anterior, vm-a com o endereço IP interno 192.168.1.2 em
subnet-a de vpc-a precisa fazer o download de uma atualização de vm-b com o endereço IP
interno 192.168.2.2 em subnet-b de vpc-b. As duas redes VPC estão conectadas ao mesmo hub do Network Connectivity Center que os spokes VPC. Suponha que vpc-b contenha outra sub-rede 192.168.1.0/24 que se sobreponha à sub-rede em vpc-a. Para que subnet-a de vpc-a se comunique com subnet-b
de vpc-b, é necessário configurar um gateway NAT particular, pvt-nat-gw,
em vpc-a da seguinte maneira:
Sub-rede NAT particular: antes de configurar o gateway NAT
particular, crie uma sub-rede NAT particular de finalidade PRIVATE_NAT,
por exemplo, 10.1.2.0/29. Verifique se essa sub-rede não se sobrepõe
a uma sub-rede existente em nenhum dos spokes VPC anexados ao
mesmo hub do Network Connectivity Center.
Uma regra NAT cujo nexthop.hub corresponde ao URL do hub do Network Connectivity Center.
NAT para todos os intervalos de endereços de subnet-a.
A tabela a seguir resume a configuração de rede especificada no exemplo anterior:
Nome da rede
Componente de rede
Endereço / intervalo IP
Região
vpc-a
subnet-a
192.168.1.0/24
us-east1
vm-a
192.168.1.2
pvt-nat-gw
10.1.2.0/29
vpc-b
subnet-b
192.168.2.0/24
us-west1
vm-b
192.168.2.2
subnet-c
192.168.1.0/24
vm-c
192.168.1.3
O Private NAT para os spokes do Network Connectivity Center segue o
procedimento de reserva de porta
para reservar o seguinte endereço IP de origem NAT
e as tuplas de origem da NAT para cada uma das VMs na rede. Por exemplo, o gateway do Private NAT reserva 64 portas de origem para vm-a: 10.1.2.2:34000 a 10.1.2.2:34063.
Quando a VM usa o protocolo TCP para enviar um pacote ao servidor de atualização
192.168.2.2 na porta de destino 80, ocorre o seguinte:
A VM envia um pacote de solicitação com estes atributos:
Endereço IP de origem: 192.168.1.2, o endereço IP interno da VM
Porta de origem: 24000, a porta de origem temporária escolhida pelo sistema operacional da VM
Endereço de destino: 192.168.2.2, o endereço IP do servidor de atualização
Porta de destino: 80, a porta de destino do tráfego HTTP para o servidor de atualizações
Protocolo: TCP
O gateway pvt-nat-gw executa a conversão de endereços de rede de origem (SNAT, na sigla em inglês) (SNAT ou NAT de origem) na saída, reescrevendo o endereço IP de origem e a porta de origem do pacote de solicitação:
Endereço IP de origem NAT: 10.1.2.2, de um dos endereços IP de origem NAT
reservados da VM e das tuplas da porta de origem
Porta de origem: 34022, uma porta de origem não utilizada de uma das tuplas de porta de origem reservadas da VM
Endereço de destino: 192.168.2.2, inalterado
Porta de destino: 80, inalterada
Protocolo: TCP, inalterado
O servidor de atualização envia um pacote de resposta que chega ao
gateway pvt-nat-gw com estes atributos:
Endereço IP de origem: 192.168.2.2, o endereço IP interno do servidor de atualização
Porta de origem: 80, a resposta HTTP do servidor de atualização
Endereço de destino: 10.1.2.2, que corresponde ao endereço IP de origem da NAT original
do pacote de solicitação
Porta de destino: 34022, que corresponde à porta de origem do pacote de solicitação
Protocolo: TCP, inalterado
O gateway pvt-nat-gw executa a conversão de endereços de rede de destino (DNAT, na sigla em inglês) no pacote de resposta, reescrevendo o endereço de destino e a porta de destino do pacote de resposta para que o pacote seja entregue à VM que solicitou a atualização com o seguinte atributos:
Endereço IP de origem: 192.168.2.2, inalterado
Porta de origem: 80, inalterada
Endereço de destino: 192.168.1.2, o endereço IP interno da VM
Porta de destino: 24000, que corresponde à porta de origem temporária original do pacote de solicitação
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-19 UTC."],[],[],null,["# Private NAT for Network Connectivity Center spokes\n==================================================\n\nPrivate NAT lets you create a Private NAT\ngateway that works in conjunction with Network Connectivity Center\nspokes to perform network address translation (NAT) between the following\nnetworks:\n\n- Virtual Private Cloud (VPC) networks: In this scenario, the VPC networks that you want to connect are attached to a Network Connectivity Center hub as VPC spokes.\n- VPC networks and networks outside of Google Cloud: In this scenario, one or more VPC networks are attached to a Network Connectivity Center hub as VPC spokes and connected to your on-premises or other cloud provider networks through hybrid spokes.\n\nSpecifications\n--------------\n\nIn addition to the [general Private NAT specifications](/nat/docs/private-nat#pvt-nat-specs),\nPrivate NAT for Network Connectivity Center spokes has the following\nspecifications:\n\n- Private NAT uses a NAT configuration of `type=PRIVATE` to let networks with overlapping subnet IP address ranges communicate. However, only non-overlapping subnets can connect to each other.\n- You need to create a custom NAT rule by referencing a Network Connectivity Center hub. The NAT rule specifies a NAT IP address range from a subnet of purpose `PRIVATE_NAT` that Private NAT uses to perform NAT on traffic between your connected networks.\n- When you create a VM instance in a subnet range where the Private NAT applies, all egress traffic from this VM instance is translated by the gateway if the destination spoke is in the same Network Connectivity Center hub as the gateway. Private NAT translates traffic to destination spokes within the same region as the Private NAT gateway as well as across regions.\n- A Private NAT gateway is associated with subnet IP address ranges in a single region in a single VPC network. This means a Private NAT gateway created in one VPC network doesn't provide NAT services to VMs in other spokes of the Network Connectivity Center hub, even if the VMs are in the same region as the gateway.\n\n### Traffic between VPC networks\n\nThe following additional specifications apply for traffic between\nVPC networks (Inter-VPC NAT):\n\n- To enable Inter-VPC NAT between two VPC networks, each VPC network must be configured as a VPC spoke of a Network Connectivity Center hub. You must ensure that there are no overlapping IP address ranges across your VPC spokes. For more information, see [Create a VPC spoke](/network-connectivity/docs/network-connectivity-center/how-to/working-with-hubs-spokes#create-vpc-spoke).\n- The Network Connectivity Center hub associated with the Private NAT gateway must have at least two VPC spokes, where one of the VPC spokes is the VPC network of the Private NAT gateway.\n- Inter-VPC NAT supports NAT between Network Connectivity Center VPC spokes only, and not between VPC networks connected using VPC Network Peering.\n\n### Traffic between VPC networks and other networks\n\nThe following additional specifications apply for traffic between\nVPC networks and networks outside of Google Cloud:\n\n- The source VPC network must be configured as a VPC spoke of a Network Connectivity Center hub.\n- A hybrid spoke must be attached to the same Network Connectivity Center hub to establish connectivity between the VPC spoke and the destination network outside of Google Cloud. For more information, see [Establishing connectivity between hybrid spokes and VPC spokes](/network-connectivity/docs/network-connectivity-center/concepts/dynamic-route-exchange-with-vpc-spokes#connectivity-between-hybrid-and-vpc-spokes).\n\nFor information about the requirements for using VPC spokes and\nhybrid spokes in the same Network Connectivity Center hub, see\n[Route exchange with VPC spokes](/network-connectivity/docs/network-connectivity-center/concepts/dynamic-route-exchange-with-vpc-spokes).\n\nBasic configuration and workflow\n--------------------------------\n\nThe following diagram shows a basic Private NAT configuration\nfor traffic between two VPC spokes:\n[](/static/nat/images/inter-vpc-nat-flow.png) Inter-VPC NAT translation example (click to enlarge).\n\nIn this example, Private NAT is set up as follows:\n\n- The `pvt-nat-gw` gateway is configured in `vpc-a` to apply to all the IP address ranges of `subnet-a` in the `us-east1` region. Using the NAT IP ranges of `pvt-nat-gw`, a virtual machine (VM) instance in `subnet-a` of `vpc-a` can send traffic to a VM in `subnet-b` of `vpc-b`, even though `subnet-a` of `vpc-a` overlaps with `subnet-c` of `vpc-b`.\n- Both `vpc-a` and `vpc-b` are configured as spokes of a Network Connectivity Center hub.\n- The `pvt-nat-gw` gateway is configured to provide NAT between VPC networks that are configured as VPC spokes in the same Network Connectivity Center hub.\n\n### Example workflow\n\nIn the preceding diagram, `vm-a` with the internal IP address `192.168.1.2` in\n`subnet-a` of `vpc-a` needs to download an update from `vm-b` with the internal\nIP address `192.168.2.2` in `subnet-b` of `vpc-b`. Both the VPC\nnetworks are connected to the same Network Connectivity Center hub as VPC\nspokes. Assume that `vpc-b` contains another subnet `192.168.1.0/24` that overlaps\nwith the subnet in `vpc-a`. For `subnet-a` of `vpc-a` to communicate with `subnet-b`\nof `vpc-b`, you need to configure a Private NAT gateway, `pvt-nat-gw`,\nin `vpc-a` as follows:\n\n- Private NAT subnet: Before configuring the Private NAT\n gateway, create a Private NAT subnet of purpose `PRIVATE_NAT`,\n for example, `10.1.2.0/29`. Ensure that this subnet doesn't overlap\n with an existing subnet in any of the VPC spokes attached to the\n same Network Connectivity Center hub.\n\n- A NAT rule whose `nexthop.hub` matches the Network Connectivity Center hub URL.\n\n- NAT for all address ranges of `subnet-a`.\n\nThe following table summarizes the network configuration specified in the preceding\nexample:\n\nPrivate NAT for Network Connectivity Center spokes follows the\n[port reservation procedure](/nat/docs/ports-and-addresses#port-reservation-procedure)\nto reserve the following NAT source IP address\nand source port tuples for each of the VMs in the network. For example, the\nPrivate NAT gateway reserves 64 source ports for `vm-a`:\n`10.1.2.2:34000` through `10.1.2.2:34063`.\n\nWhen the VM uses the TCP protocol to send a packet to the update server\n`192.168.2.2` on destination port `80`, the following occurs:\n\n1. The VM sends a request packet with these attributes:\n\n - Source IP address: `192.168.1.2`, the internal IP address of the VM\n - Source port: `24000`, the ephemeral source port chosen by the VM's operating system\n - Destination address: `192.168.2.2`, the update server's IP address\n - Destination port: `80`, the destination port for HTTP traffic to the update server\n - Protocol: TCP\n2. The `pvt-nat-gw` gateway performs source network address translation (SNAT or\n source NAT) on egress, rewriting the request\n packet's NAT source IP address and source port:\n\n - NAT source IP address: `10.1.2.2`, from one of the VM's reserved NAT source IP address and source port tuples\n - Source port: `34022`, an unused source port from one of the VM's reserved source port tuples\n - Destination address: `192.168.2.2`, unchanged\n - Destination port: `80`, unchanged\n - Protocol: TCP, unchanged\n3. The update server sends a response packet that arrives on the\n `pvt-nat-gw` gateway with these attributes:\n\n - Source IP address: `192.168.2.2`, the update server's internal IP address\n - Source port: `80`, the HTTP response from the update server\n - Destination address: `10.1.2.2`, which matches the original NAT source IP address of the request packet\n - Destination port: `34022`, which matches the source port of the request packet\n - Protocol: TCP, unchanged\n4. The `pvt-nat-gw` gateway performs destination network address translation\n (DNAT) on the response packet, rewriting the response packet's destination address\n and destination port so that the packet is delivered to the VM that requested the update with the following attributes:\n\n - Source IP address: `192.168.2.2`, unchanged\n - Source port: `80`, unchanged\n - Destination address: `192.168.1.2`, the internal IP address of the VM\n - Destination port: `24000`, matching the original ephemeral source port of the request packet\n - Protocol: TCP, unchanged\n\nWhat's next\n-----------\n\n- Set up [Private NAT for Network Connectivity Center spokes](/nat/docs/set-up-private-nat).\n- Learn about [Cloud NAT product interactions](/nat/docs/nat-product-interactions).\n- Learn about [Cloud NAT addresses and ports](/nat/docs/ports-and-addresses).\n- Learn about [Cloud NAT rules](/nat/docs/nat-rules-overview).\n- Troubleshoot [common issues](/nat/docs/troubleshooting)."]]