Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Esta página fornece orientações sobre como configurar regras de firewall do Google Cloud
e suas regras de firewall de
rede de peering.
Ao configurar túneis do Cloud VPN para se conectar à sua rede de peering, revise e modifique regras de firewall no Google Cloud e em redes de peering para garantir que atendam às suas necessidades. Se a rede de peering for outra rede de nuvem privada virtual (VPC), configure
as regras de firewall do Google Cloud para os dois lados da
conexão de rede.
Para mais informações sobre o Cloud VPN, consulte os seguintes recursos:
Para conhecer as práticas recomendadas antes de configurar o Cloud VPN, consulte
Práticas recomendadas.
Para definições de termos usados nesta página, consulte Termos-chave.
Regras de firewall do Google Cloud
As regras de firewall do Google Cloud aplicam-se a pacotes enviados e recebidos
de instâncias de máquina virtual (VM) na rede VPC
e através dos túneis do Cloud VPN.
A regra de saída de permissão implícita permite que instâncias de VM e outros recursos na sua rede do Google Cloud façam solicitações de saída e recebam respostas estabelecidas. No entanto, a regra negar entrada implícita bloqueia todo o tráfego de entrada para seus recursos do Google Cloud.
Crie pelo menos uma regra de firewall para permitir o tráfego de entrada da sua rede de peering para o Google Cloud. Se você criou regras de saída para negar determinados tipos de tráfego, talvez também seja necessário criar outras regras.
O tráfego que contém os protocolos UDP 500, UDP 4500 e ESP (IPSec, protocolo IP 50)
sempre é permitido entre um ou mais endereços IP externos em um
gateway do Cloud VPN. No entanto, as regras de firewall do Google Cloud não se aplicam aos pacotes IPSec pós-encapsulados que são enviados de um gateway do Cloud VPN para um gateway de VPN de peering.
Para vários exemplos de restrição de tráfego de entrada ou saída, consulte os exemplos de configuração na documentação da VPC.
O exemplo a seguir cria uma regra de firewall de permissão de entrada. Essa regra
permite todo o tráfego TCP, UDP e ICMP do CIDR da rede de peering para as
VMs na sua rede VPC.
Permissões exigidas para a tarefa
Para executar esta tarefa, são necessárias as seguintes permissões
ou papéis do IAM.
Na seção Gateway da VPN, clique no nome da rede VPC. Essa ação leva você à página de detalhes da rede VPC que contém o túnel.
Clique na guia Regras de firewall.
Clique em Adicionar regra de firewall. Adicione uma regra para TCP, UDP e ICMP:
Nome: insira allow-tcp-udp-icmp.
Filtro de origem:selecione IPv4 ranges.
Intervalos de IPs de origem: insira um valor de Intervalo de IP da rede remota no momento em que o túnel foi criado. Caso tenha mais de um intervalo de rede de peering, insira
cada um deles. Pressione a tecla Tab entre as entradas.
Para permitir o tráfego de todos os endereços IPv4 de origem na rede de peering, especifique 0.0.0.0/0.
Portas ou protocolos especificados: selecione tcp e udp.
Outros protocolos: insira icmp.
Tags de destino: qualquer tag ou tags válidas
Clique em Criar.
Se você precisar permitir o acesso a endereços IPv6 da sua rede VPC pela rede de peering, adicione uma regra de firewall allow-ipv6-tcp-udp-icmpv6.
Clique em Adicionar regra de firewall. Adicione uma regra para TCP, UDP e ICMPv6:
Nome: insira allow-ipv6-tcp-udp-icmpv6.
Filtro de origem:selecione IPv6 ranges.
Intervalos de IPs de origem: insira um valor de Intervalo de IP da rede remota no momento em que o túnel foi criado. Caso tenha mais de um intervalo de rede de peering, insira
cada um deles. Pressione a tecla Tab entre as entradas.
Para permitir o tráfego de todos os endereços IPv6 de origem na rede de peering, especifique ::/0.
Portas ou protocolos especificados: selecione tcp e udp.
Outros protocolos: insira 58. 58 é o número do protocolo para ICMPv6.
Tags de destino: qualquer tag ou tags válidas
Clique em Criar.
Crie outras regras de firewall se for necessário.
Como alternativa, é possível criar regras a partir da página Firewall do Console do Google Cloud.
Substitua IPV4_PEER_SOURCE_RANGE por intervalos de IPv4 de origem da sua rede de peering.
Se você tiver mais de um intervalo de rede de peering, forneça uma lista separada por vírgulas
no campo de intervalos de origem
(--source-ranges 192.168.1.0/24,192.168.2.0/24).
Para permitir o tráfego de todos os endereços IPv4 de origem na rede de peering, especifique 0.0.0.0/0.
Regras de firewall IPv6
Se você precisar permitir o acesso a endereços IPv6 da sua rede VPC pela rede de peering, adicione uma regra de firewall allow-ipv6-tcp-udp-icmpv6.
Substitua PEER_SOURCE_RANGE pelos intervalos IPv6 de origem da rede de peering.
Se você tiver mais de um intervalo de rede de peering, forneça uma lista separada por vírgulas
no campo de intervalos de origem
(--source-ranges 2001:db8:aa::/64,2001:db8:bb::/64).
Para permitir o tráfego de todos os endereços IPv6 de origem na rede de peering, especifique ::/0.
Outras regras de firewall
Crie outras regras de firewall se for necessário.
Para mais informações sobre o comando firewall-rules, consulte a documentação sobre gcloud regras de firewall.
Regras de firewall de redes com peering
Ao configurar suas regras de firewall de redes com peering, considere o seguinte:
Você precisa configurar regras para permitir o tráfego de entrada e de saída entre
os intervalos de IP usados pelas sub-redes na sua rede VPC.
Outra alternativa é permitir todos os protocolos e portas ou restringir o tráfego
apenas ao conjunto de protocolos e portas necessário para atender às suas necessidades.
Permita o tráfego ICMP se você precisar usar ping para se comunicar entre sistemas de peering e instâncias ou recursos no Google Cloud.
Se você precisar acessar endereços IPv6 na sua rede de peering com ping,
permita o ICMPv6 (protocolo IP 58) no firewall de peering.
Tanto seus dispositivos de rede (dispositivos de segurança, firewalls, chaves, roteadores e gateways) quanto o software em execução nos sistemas, como o software de firewall incluído em um sistema operacional, podem implementar o firewall local. regras. Para permitir o tráfego, configure todas as regras de firewall no caminho para sua rede VPC corretamente.
Se seu túnel da VPN usa roteamento dinâmico (BGP), permita o tráfego BGP para os endereços IP link-local. Para mais detalhes, consulte a próxima seção.
Considerações sobre o BGP para gateways de peering
As trocas de roteamento dinâmico (BGP) encaminham informações usando a porta TCP 179. Alguns gateways da VPN,
incluindo gateways do Cloud VPN, permitem esse tráfego automaticamente
quando você escolhe o roteamento dinâmico. Se o gateway da VPN de peering não permitir, você precisa
configurá-lo para permitir tráfego de entrada e saída na porta TCP 179. Todos os endereços IP BGP
usam o bloco CIDR 169.254.0.0/16 de link local.
Se o gateway da VPN de peering não estiver diretamente conectado à Internet,
verifique se os roteadores, firewalls e dispositivos de segurança de peering estão configurados
para passar pelo menos o tráfego BGP (porta TCP 179) e o tráfego ICMP para o
gateway da VPN. O ICMP não é obrigatório, mas é útil para testar a conectividade entre um Cloud Router e o gateway da VPN. O intervalo de endereços IP ao qual sua regra de firewall de peering deve ser aplicada precisa incluir os endereços IP do BGP do Cloud Router e seu gateway.
A seguir
Para garantir que os componentes estejam se comunicando corretamente com o Cloud VPN,
consulte Como verificar o status da VPN.
Para usar cenários de alta disponibilidade e alta capacidade ou vários cenários de sub-rede, consulte Configurações avançadas.
Para ajudar a resolver problemas comuns que você pode encontrar ao usar o
Cloud VPN, consulte Solução de problemas.
[[["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 2024-12-05 UTC."],[],[],null,["# Configure firewall rules\n\nThis page provides guidance for configuring Google Cloud firewall\nrules and your peer network firewall rules.\n\nWhen you configure Cloud VPN tunnels to connect to your peer network,\nreview and modify firewall rules in your Google Cloud and peer networks\nto make sure that they meet your needs. If your peer network is another\nVirtual Private Cloud (VPC) network, then configure Google Cloud firewall\nrules for both sides of the network connection.\n| **Note:** If your Cloud VPN tunnel uses [dynamic (BGP) routing](/network-connectivity/docs/vpn/concepts/choosing-networks-routing#dynamic-routing), make sure that your on-premises network and VPN gateway [allow BGP traffic](#dynamic-rules) so that route information can be exchanged.\n\nFor more information about Cloud VPN, see the following resources:\n\n- For best practices to consider before setting up Cloud VPN, see\n [Best practices](/network-connectivity/docs/vpn/concepts/best-practices).\n\n- For more information about Cloud VPN, see the\n [Cloud VPN overview](/network-connectivity/docs/vpn/concepts/overview).\n\n- For definitions of terms used on this page, see\n [Key terms](/network-connectivity/docs/vpn/concepts/key-terms).\n\nGoogle Cloud firewall rules\n---------------------------\n\nGoogle Cloud firewall rules apply to packets sent to and\nfrom virtual machine (VM) instances within your VPC network\nand through Cloud VPN tunnels.\n\nThe [implied allow egress](/vpc/docs/firewalls#default_firewall_rules) rules\nallow VM instances and other resources in your Google Cloud network to\nmake outgoing requests and receive established responses. However, the\n[implied deny ingress](/vpc/docs/firewalls#default_firewall_rules) rule blocks\nall incoming traffic to your Google Cloud resources.\n\nAt a minimum, create firewall rules to allow ingress traffic from\nyour peer network to Google Cloud. If you created egress rules to\n*deny* certain types of traffic, you might also need to create other egress\nrules.\n\nTraffic containing the protocols UDP 500, UDP 4500, and ESP\n(IPsec, IP protocol 50) is always allowed to and from one or more external IP\naddresses on a Cloud VPN gateway. However, Google Cloud firewall\nrules do *not* apply to the\n[post-encapsulated IPsec packets](https://wikipedia.org/wiki/IP_in_IP)\nthat are sent from a Cloud VPN gateway to a peer VPN gateway.\n\nFor more information about Google Cloud firewall rules, see the\n[VPC firewall rules overview](/vpc/docs/firewalls).\n\n### Example configurations\n\nFor multiple examples of restricting ingress or egress traffic, see the\n[configuration examples](/vpc/docs/using-firewalls#configuration_examples)\nin the VPC documentation.\n\nThe following example creates an *ingress allow* firewall rule. This rule\npermits all TCP, UDP, and ICMP traffic from your peer network's CIDR to your\nVMs in your VPC network.\n\n#### Permissions required for this task\n\nTo perform this task, you must have been granted the following permissions\n*or* the following IAM roles.\n\n**Roles**\n\n- [`roles/compute.securityAdmin`](/compute/docs/access/iam#compute.securityAdmin) \n\n### Console\n\n1. In the Google Cloud console, go to the **VPN tunnels** page.\n\n [Go to VPN tunnels](https://console.cloud.google.com/vpn/list?tab=tunnels)\n2. Click the VPN tunnel that you want to use.\n\n3. In the **VPN gateway** section, click the name of the VPC\n network. This action directs you to the **VPC network details** page that\n contains the tunnel.\n\n4. Click the **Firewall rules** tab.\n\n5. Click **Add firewall rule**. Add a rule for TCP, UDP, and ICMP:\n\n - **Name:** Enter `allow-tcp-udp-icmp`.\n - **Source filter:** Select **IPv4 ranges**.\n - **Source IP ranges:** Enter a **Remote network IP range** value from when you created the tunnel. If you have more than one peer network range, enter each one. Press the **Tab** key between entries. To allow traffic from all source IPv4 addresses in your peer network, specify `0.0.0.0/0`.\n - **Specified protocols or ports:** Select `tcp` and `udp`.\n - **Other protocols:** Enter `icmp`.\n - **Target tags:** Add any valid tag or tags.\n6. Click **Create**.\n\nIf you need to allow access to IPv6 addresses on your VPC network from your peer network, add an `allow-ipv6-tcp-udp-icmpv6` firewall rule.\n\n1. Click **Add firewall rule** . Add a rule for TCP, UDP, and ICMPv6:\n - **Name:** Enter `allow-ipv6-tcp-udp-icmpv6`.\n - **Source filter:** Select **IPv6 ranges**.\n - **Source IP ranges:** Enter a **Remote network IP range** value from when you created the tunnel. If you have more than one peer network range, enter each one. Press the **Tab** key between entries. To allow traffic from all source IPv6 addresses in your peer network, specify `::/0`.\n - **Specified protocols or ports:** Select `tcp` and `udp`.\n - **Other protocols** : Enter `58`. 58 is the protocol number for ICMPv6.\n - **Target tags:** Add any valid tag or tags.\n2. Click **Create**.\n\nCreate other firewall rules if necessary.\n\nAlternatively, you can create rules from the Google Cloud console\n**Firewall** page.\n\n### gcloud\n\nRun the following command: \n\n```\ngcloud compute --project PROJECT_ID firewall-rules create allow-tcp-udp-icmp \\\n --network NETWORK \\\n --allow tcp,udp,icmp \\\n --source-ranges IPV4_PEER_SOURCE_RANGE\n```\n\nReplace \u003cvar translate=\"no\"\u003eIPV4_PEER_SOURCE_RANGE\u003c/var\u003e with source IPv4 ranges from your peer network.\n\nIf you have more than one peer network range, provide a comma-separated\nlist in the source-ranges field\n(`--source-ranges 192.168.1.0/24,192.168.2.0/24`).\n\nTo allow traffic from all source IPv4 addresses in your peer network, specify `0.0.0.0/0`.\n\n**IPv6 firewall rules**\n\nIf you need to allow access to IPv6 addresses on your VPC network from your peer network, add an `allow-ipv6-tcp-udp-icmpv6` firewall rule. \n\n```\ngcloud compute --project PROJECT_ID firewall-rules create allow-ipv6-tcp-udp-icmpv6 \\\n --network NETWORK \\\n --allow tcp,udp,58 \\\n --source-ranges IPV6_PEER_SOURCE_RANGE\n```\n\n58 is the protocol number for ICMPv6.\n\nReplace \u003cvar translate=\"no\"\u003ePEER_SOURCE_RANGE\u003c/var\u003e with source IPv6 ranges from your peer network.\nIf you have more than one peer network range, provide a comma-separated\nlist in the source-ranges field\n(`--source-ranges 2001:db8:aa::/64,2001:db8:bb::/64`).\n\nTo allow traffic from all source IPv6 addresses in your peer network, specify `::/0`.\n\n**Other firewall rules**\n\nCreate other firewall rules if necessary.\n\nFor more information about the `firewall-rules` command, see the\n[`gcloud` firewall rules](/sdk/gcloud/reference/compute/firewall-rules)\ndocumentation.\n\nPeer firewall rules\n-------------------\n\nWhen configuring your peer firewall rules, consider the following:\n\n- Configure rules to allow egress and ingress traffic to and from the IP ranges used by the subnets in your VPC network.\n- You can choose to permit all protocols and ports, or you can restrict traffic to only the necessary set of protocols and ports to meet your needs.\n- Allow ICMP traffic if you need to use `ping` to be able to communicate among peer systems and instances or resources in Google Cloud.\n- If you need to access IPv6 addresses on your peer network with `ping`, allow ICMPv6 (IP protocol 58) in your peer firewall.\n- Both your network devices (security appliances, firewall devices, switches, routers, and gateways) and software running on your systems (such as firewall software included with an operating system) can implement on-premises firewall rules. To allow traffic, configure all firewall rules in the path to your VPC network appropriately.\n- If your VPN tunnel uses dynamic (BGP) routing, make sure that you allow BGP traffic for the link-local IP addresses. For more details, see the next section.\n\n### BGP considerations for peer gateways\n\nDynamic (BGP) routing exchanges route information by using TCP port 179. Some VPN\ngateways, including Cloud VPN gateways, allow this traffic automatically\nwhen you choose dynamic routing. If your peer VPN gateway does not,\nconfigure it to allow incoming and outgoing traffic on TCP port 179. All BGP\nIP addresses use the link-local `169.254.0.0/16` CIDR block.\n\nIf your peer VPN gateway is not directly connected to the internet, make\nsure that it and peer routers, firewall rules, and security appliances are\nconfigured to at least pass BGP traffic (TCP port 179) and ICMP traffic to your\nVPN gateway. ICMP is not required, but it is useful to test connectivity between\na Cloud Router and your VPN gateway. The range of IP addresses to which\nyour peer firewall rule should apply must include the BGP IP addresses of the\nCloud Router and your gateway.\n\nWhat's next\n-----------\n\n- To make sure components are communicating correctly with Cloud VPN, see [Check VPN status](/network-connectivity/docs/vpn/how-to/checking-vpn-status).\n- To use high-availability and high-throughput scenarios or multiple subnet scenarios, see [Advanced configurations](/network-connectivity/docs/vpn/concepts/advanced).\n- To help you solve common issues that you might encounter when using Cloud VPN, see [Troubleshooting](/network-connectivity/docs/vpn/support/troubleshooting)."]]