Como proteger o IAP para encaminhamento de TCP com o VPC Service Controls
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Nesta página, descrevemos como usar o VPC Service Controls para proteger
o IAP para encaminhamento de TCP e como usar o IAP
para encaminhamento de TCP em um perímetro do VPC Service Controls.
Adicione o projeto que contém a instância do Compute Engine a que
você quer se conectar com o IAP aos projetos dentro
do perímetro de serviço. Se você estiver executando um IAP para cliente TCP
em uma instância do Compute Engine, coloque também o projeto
que contém essa instância no perímetro.
Adicione a API Identity-Aware Proxy TCP à lista de serviços protegidos pelo
perímetro de serviço.
Se você criou o perímetro de serviço
sem adicionar os projetos e
serviços necessários, consulte
Como gerenciar perímetros de
serviço para saber como atualizá-lo.
Configurar registros DNS usando o Cloud DNS
Se o IAP para cliente TCP, que provavelmente é a
CLI do Google Cloud, não estiver sendo executado em nenhum perímetro, pule esta etapa. Por outro lado, se você executar o cliente dentro de um
perímetro, será necessário configurar os registros DNS para o IAP para TCP.
O IAP para TCP usa domínios que não são subdomínios de
googleapis.com. Ao usar o Cloud DNS, adicione registros DNS para garantir que a
rede VPC processe corretamente as solicitações enviadas a esses domínios. Para
mais informações sobre rotas VPC, consulte
Visão geral de rotas.
Siga as etapas a seguir para criar uma zona gerenciada de um domínio, adicionar
registros DNS a fim de rotear solicitações e executar a transação. Use a
CLI gcloud com seu terminal preferido ou o
Cloud Shell, que tem a
CLI gcloud pré-instalada.
Configure
o DNS *.googleapis.com como é comum para integrações do
VPC Service Controls.
Colete estas informações para usar ao configurar os registros DNS:
PROJECT_ID é o código do projeto que hospeda sua
rede VPC.
NETWORK_NAME é o nome da rede VPC em que
você está executando o IAP para o cliente TCP.
ZONE_NAME é um nome para a zona que você está criando. Por exemplo, iap-tcp-zone.
Crie uma zona gerenciada privada para o domínio tunnel.cloudproxy.app para que a rede
VPC possa processá-la.
gclouddnsmanaged-zonescreateZONE_NAME\--visibility=private\--networks=https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/networks/NETWORK_NAME\--dns-name=tunnel.cloudproxy.app\--description="Description of your managed zone"
Inclua o registro CNAME DNS a seguir para apontar para o registro A que você acabou
de adicionar. Isso redireciona todo o tráfego que corresponde ao domínio para os
endereços IP listados na etapa anterior.
Em vez de usar o Cloud DNS, é possível usar
o BIND. Nesse caso,
siga as instruções para
configurar o DNS com
o BIND,
mas use o IAP para domínios TCP em
vez dos domínios googleapis.com gerais.
Como usar o VIP particular
Em vez de usar o VIP restrito, talvez seja possível usar o
VIP privado,
dependendo de como você configurou o perímetro e a rede. Se você preferir
fazer isso, use
[[["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-18 UTC."],[[["\u003cp\u003eThis page explains how to use VPC Service Controls to safeguard IAP for TCP forwarding, including using IAP for TCP forwarding within a VPC Service Controls perimeter.\u003c/p\u003e\n"],["\u003cp\u003eA service perimeter can be created to protect Google-managed resources, and when doing so, the project with the Compute Engine instance must be added, as well as Identity-Aware Proxy TCP API.\u003c/p\u003e\n"],["\u003cp\u003eDNS records need to be configured for IAP for TCP if the client runs inside a perimeter, ensuring that the VPC network properly handles requests to non-\u003ccode\u003egoogleapis.com\u003c/code\u003e domains, especially \u003ccode\u003etunnel.cloudproxy.app\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eTo configure DNS, a private managed zone is created for \u003ccode\u003etunnel.cloudproxy.app\u003c/code\u003e, with DNS A and CNAME records added to reroute traffic to Google's restricted VIP or the private VIP, depending on network configuration.\u003c/p\u003e\n"],["\u003cp\u003eWhen utilizing a shared VPC, it's essential to include both the host and service projects within the service perimeter to maintain proper access control.\u003c/p\u003e\n"]]],[],null,["# Securing IAP for TCP forwarding with VPC Service Controls\n\nThis page describes how to use VPC Service Controls to protect\nIAP for TCP forwarding, and how to use IAP\nfor TCP forwarding within a VPC Service Controls perimeter.\n\nBefore you begin\n----------------\n\n1. Read the [Overview of\n VPC Service Controls](/vpc-service-controls/docs/overview).\n\n2. [Set up](/iap/docs/using-tcp-forwarding) usage of IAP TCP\n forwarding without a service perimeter.\n\n3. [Create a service perimeter using\n VPC Service Controls](/vpc-service-controls/docs/create-service-perimeters).\n This service perimeter protects the Google-managed resources of services\n that you specify. When you create your service perimeter, do the following:\n\n 1. Add the project that contains the Compute Engine instance you want to\n connect to with IAP to the projects within your\n service perimeter. If you are running an IAP for TCP\n client on a Compute Engine instance, also put the project\n containing this instance into the perimeter.\n\n 2. Add **Identity-Aware Proxy TCP API** to the list of services protected by your\n service perimeter.\n\n If you created your service perimeter without adding the projects and\n services you need, see\n [Managing service\n perimeters](/vpc-service-controls/docs/manage-service-perimeters)\n to learn how to update your service perimeter.\n\nConfigure your DNS records using Cloud DNS\n------------------------------------------\n\nIf your IAP for TCP client, which is likely the\n[Google Cloud CLI](/sdk/gcloud), is not running inside any perimeter, then\nyou can skip this step. On the other hand, if you run the client inside a\nperimeter, you must configure DNS records for IAP for TCP.\n\nIAP for TCP uses domains that are not subdomains of\n`googleapis.com`. Using Cloud DNS, add DNS records to ensure that your\nVPC network correctly handles requests sent to those domains. To\nlearn more about VPC routes, read the\n[Routes overview](/vpc/docs/routes).\n\nUse the following steps to create a [managed zone](/dns/zones) for a domain, add\nDNS records to route requests, and execute the transaction. You can use the\ngcloud CLI with your preferred terminal or use\n[Cloud Shell](/shell/docs/using-cloud-shell), which has the\ngcloud CLI preinstalled.\n\n1. [Configure](/vpc-service-controls/docs/set-up-private-connectivity#configuring_dns_with)\n the `*.googleapis.com` DNS as is typical for VPC Service Controls\n integrations.\n\n2. Collect this information to use when configuring your DNS records:\n\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e is the ID of the project that hosts your\n VPC network.\n\n - \u003cvar translate=\"no\"\u003eNETWORK_NAME\u003c/var\u003e is the name of the VPC network in\n which you are running your IAP for TCP client.\n\n - \u003cvar translate=\"no\"\u003eZONE_NAME\u003c/var\u003e is a name for the zone that you are creating. For\n example, `iap-tcp-zone`.\n\n3. Create a private managed zone for the domain `tunnel.cloudproxy.app` so the\n VPC network can handle it.\n\n ```bash\n gcloud dns managed-zones create ZONE_NAME \\\n --visibility=private \\\n --networks=https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/networks/NETWORK_NAME \\\n --dns-name=tunnel.cloudproxy.app \\\n --description=\"Description of your managed zone\"\n ```\n4. Start a transaction.\n\n ```bash\n gcloud dns record-sets transaction start --zone=ZONE_NAME\n ```\n5. Add the following DNS A record. This reroutes traffic to Google's\n [restricted VIP](/vpc-service-controls/docs/set-up-private-connectivity)\n (virtual IP address).\n\n ```bash\n gcloud dns record-sets transaction add \\\n --name=tunnel.cloudproxy.app. \\\n --type=A 199.36.153.4 199.36.153.5 199.36.153.6 199.36.153.7 \\\n --zone=ZONE_NAME \\\n --ttl=300\n ```\n6. Add the following DNS CNAME record to point to the A record that you just\n added. This redirects all traffic matching the domain to the IP addresses\n listed in the previous step.\n\n ```bash\n gcloud dns record-sets transaction add \\\n --name=\"*.tunnel.cloudproxy.app.\" \\\n --type=CNAME tunnel.cloudproxy.app. \\\n --zone=ZONE_NAME \\\n --ttl=300\n ```\n7. Execute the transaction.\n\n ```bash\n gcloud dns record-sets transaction execute --zone=ZONE_NAME\n ```\n\n### Configuring DNS with BIND\n\nInstead of using Cloud DNS, you can use\n[BIND](https://www.wikipedia.org/wiki/BIND). In that case,\nfollow the directions for\n[configuring DNS with\nBIND](/vpc-service-controls/docs/set-up-private-connectivity#configuring_dns_with_bind),\nbut use the IAP for TCP domains instead of the general\n`googleapis.com` domains.\n\n### Using the private VIP\n\nInstead of using the restricted VIP, it might be possible to use the\n[private VIP](/vpc/docs/configure-private-google-access-hybrid#config-choose-domain),\ndepending on how you've configured your perimeter and network. If you prefer to\ndo that, then use\n\n`199.36.153.8 199.36.153.9 199.36.153.10 199.36.153.11`\n\nin place of\n\n`199.36.153.4 199.36.153.5 199.36.153.6 199.36.153.7`\n\nin the instructions for configuring your DNS records.\n\nUsing a shared VPC\n------------------\n\nIf you're using a [shared VPC](/vpc/docs/shared-vpc),\nyou must add the host and the service projects to the service perimeter. See\n[Managing service\nperimeters](/vpc-service-controls/docs/manage-service-perimeters).\n\nWhat's next\n-----------\n\n- See [Managing service\n perimeters](/vpc-service-controls/docs/manage-service-perimeters) to add more resources to your service perimeter."]]