Google Cloud ファイアウォール ルールは、Cloud VPN トンネル経由で VPC ネットワーク内の仮想マシン(VM)インスタンス間で送受信されるパケットに適用されます。
暗黙の下り(外向き)許可ルールは、 Google Cloud ネットワーク内の VM インスタンスや他のリソースが発信リクエストを行って確立されたレスポンスを受信することを許可します。ただし、暗黙の上り(内向き)拒否ルールは、 Google Cloud リソースへの着信トラフィックをすべてブロックします。
ピア ネットワークから Google Cloudへの上り(内向き)トラフィックを許可するには、少なくともファイアウォール ルールは作成する必要があります。特定の種類のトラフィックを拒否する下り(外向き)ルールを作成した場合は、他の下り(外向き)ルールの作成も必要になることがあります。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-09-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)."]]