このページでは、Private Service Connect のポート マッピングの概要について説明します。
Private Service Connect ポート マッピングを使用すると、コンシューマー仮想マシン(VM)インスタンスは、1 つの Private Service Connect エンドポイントを介して、特定のプロデューサー VM の特定のサービスポートと非公開で通信できます。
サービス コンシューマーは、エンドポイントのさまざまなクライアント宛先ポートにトラフィックを送信します。Private Service Connect は、プロデューサー定義のマッピングを使用して、指定されたサービスポートとプロデューサー VM にトラフィックを転送します。ネットワークのコンテキストによっては、この方法はポート転送とも呼ばれます。
ポート マッピングと通常の Private Service Connect
マネージド サービスは、多くの場合、VM のクラスタとして設計されます。異なる VM は、同じサービスの個別のインスタンスを表します。すべての VM は、同じポートで同じオペレーションを公開します。たとえば、データベース サービスは、データベースの読み取りオペレーションにポート 1000 を使用し、データベースの書き込みオペレーションにポート 2000 を使用します。コンシューマー VM は、サービス インスタンスに関連付けられた VM のポートをターゲットに指定して、特定のサービス インスタンスと通信します。
Private Service Connect エンドポイントとサービス アタッチメント間の通常の接続(ロード バランシングされた接続)は、この状況には適していません。通常の Private Service Connect 接続では、コンシューマー VM はエンドポイントの IP アドレスの 1 つ以上のポートにトラフィックを送信します。すべてのトラフィックがロードバランスされ、トラフィックを受信するポートのバックエンドとして構成されている正常なプロデューサー VM に送信されます。
一方、Private Service Connect ポート マッピングではロード バランシングは行われません。この方法では、コンシューマー VM は、トラフィックを受信するクライアント宛先ポートに基づいて、特定のプロデューサー VM の特定のサービスポートをターゲットに設定できます。
Private Service Connect ポート マッピングは、ポート マッピング NEG 用に構成されたマッピングに基づいて、エンドポイントのクライアント宛先ポートからプロデューサー VM のサービスポートにトラフィックを転送します(クリックして拡大)。
Private Service Connect ポート マッピングを使用すると、コンシューマー VM は次のプロセスで特定のプロデューサー VM と通信できます。
コンシューマー VM は、指定されたクライアント宛先ポートを使用して、エンドポイントの IP アドレスにパケットを送信します。クライアントの宛先ポートは、パケットの宛先 VM とポートの固有識別子として機能します。
Private Service Connect は、トラフィックを受信するクライアント宛先ポートのマッピングを使用して、パケットの宛先を決定します。
Private Service Connect は、トラフィックを宛先 VM とサービスポートに転送します。
[[["わかりやすい","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-08-19 UTC。"],[],[],null,["# About Private Service Connect port mapping\n==========================================\n\nThis page provides an overview of Private Service Connect port mapping.\n\nPrivate Service Connect port mapping lets consumer\nvirtual machine (VM) instances privately communicate with specific service ports\non specific producer VMs through a single Private Service Connect\nendpoint.\n\nA service consumer sends traffic to various client destination ports of the\nendpoint. Private Service Connect uses producer-defined mappings\nto forward traffic to the specified service port and producer VM. In some\nnetworking contexts, this approach is also known as port forwarding.\n\nPort mapping versus regular Private Service Connect\n---------------------------------------------------\n\nManaged services are often designed as clusters of VMs, where\ndifferent VMs represent separate instances of the same service. Every VM\nexposes the same operations on the same ports. For example, a\ndatabase service might use port `1000` for database read operations and\nport `2000` for database write operations. Consumer VMs communicate with\nspecific service instances by targeting ports on the VMs that are associated\nwith the service instance.\n\nA regular (load balanced) connection between a\n[Private Service Connect endpoint](/vpc/docs/about-accessing-vpc-hosted-services-endpoints)\nand a\n[service attachment](/vpc/docs/about-vpc-hosted-services#service-attachments)\nis not ideal for this situation. With a regular\nPrivate Service Connect connection, consumer VMs send traffic to\none or more ports of the endpoint's IP address. All traffic is load balanced and\nsent to any healthy producer VM that is configured as a backend for the port\nthat receives the traffic.\n\nIn contrast, Private Service Connect port mapping eliminates\nload balancing. This approach lets consumer VMs target specific service ports\nof specific producer VMs based on the client destination port that receives\nthe traffic.\n[](/static/vpc/images/psc-port-mapping-overview.svg) Private Service Connect port mapping forwards traffic from client destination ports of an endpoint to service ports of producer VMs based on mapping that is configured for a port mapping NEG (click to enlarge).\n\nPrivate Service Connect port mapping lets consumer VMs communicate\nwith specific producer VMs through the following process:\n\n1. The consumer VM sends packets to the endpoint's IP address, using a designated client destination port. The client destination port acts as a unique identifier for the packet's intended destination VM and port.\n2. Private Service Connect uses the mapping of the client destination port that receives the traffic to determine the packet's destination.\n3. Private Service Connect forwards the traffic to its destination VM and service port.\n\nFor example, in figure 1, packets are forwarded as follows:\n\n- Packets that are sent to client destination port `1001` of the endpoint are forwarded to service port `1000` of `vm-1`.\n- Packets that are sent to client destination port `1002` of the endpoint are forwarded to service port `2000` of `vm-1`.\n- Packets that are sent to client destination port `1003` of the endpoint are forwarded to service port `1000` of `vm-2`.\n- Packets that are sent to client destination port `1004` of the endpoint are forwarded to service port `2000` of `vm-2`.\n\nDeployment\n----------\n\nDeploying a Private Service Connect port mapping connection\ndiffers from deploying a regular Private Service Connect\nendpoint connection for published services in the following ways:\n\n1. The service producer creates a port mapping service. Port mapping services use [port mapping network endpoint groups (NEGs)](/vpc/docs/create-port-mapping-service#create-neg). This configuration is similar to an internal passthrough Network Load Balancer, but traffic is not load balanced.\n2. The service producer [configures the port mapping NEG's network endpoints](/vpc/docs/create-port-mapping-service?#add-endpoints) to specify mappings from client destination ports of a Private Service Connect endpoint to service ports of specific producer VMs.\n3. The service producer creates a service attachment that is associated with the forwarding rule of their port mapping service.\n4. The service producer shares client destination ports and their mappings with the service consumer. This is not handled automatically by Google Cloud.\n5. The service consumer configures workloads to communicate with managed services by using the producer-defined port mappings.\n\nSpecifications\n--------------\n\nPrivate Service Connect port mapping has the following\nspecifications:\n\n- A Private Service Connect port mapping connection requires a Private Service Connect endpoint in a consumer VPC network that connects to a service attachment in a producer VPC network.\n- The service attachment is associated with a port mapping service. Port mapping services are configured similarly to internal passthrough Network Load Balancers, but traffic isn't load balanced. Port mapping services are composed of the following:\n - A [forwarding rule](/load-balancing/docs/forwarding-rule-concepts) that connects to a backend service. The forwarding rule must be configured for either `TCP` or `UDP` traffic. The forwarding rule must be configured to forward traffic for all client destination ports---for example, by specifying `--ports=ALL` in the Google Cloud CLI. However, you only need to define mappings in the port mapping NEG for the client destination ports that you plan to use.\n - A [backend service](/load-balancing/docs/backend-service) that is configured to use a [port mapping network endpoint group\n (NEG)](/load-balancing/docs/negs#port-mapping-neg). Service producers use the network endpoints of the port mapping NEG to define unique mappings from client destination ports of the Private Service Connect endpoint to a combination of service port and producer VM.\n- Instead of load balancing traffic, the port mapping service forwards traffic based solely on the mappings that are configured in the port mapping NEG.\n- The producer service must share the valid client destination ports and their respective mappings with the consumer. Private Service Connect doesn't share this information with the consumer.\n- The consumer must configure their workloads to communicate with managed services by using the producer-defined port mappings.\n- Consumers can enable [global\n access](/vpc/docs/about-accessing-vpc-hosted-services-endpoints#global-access) for endpoints that connect to port mapping services if global access is enabled on the service's forwarding rule.\n- Private Service Connect port mapping supports hybrid access. A consumer's on-premises workload can reach producer VMs by accessing the Private Service Connect endpoint through [VLAN attachments for\n Cloud Interconnect](/network-connectivity/docs/interconnect/concepts/overview) or [Cloud VPN](/network-connectivity/docs/vpn/concepts/overview).\n- Private Service Connect port mapping supports [propagated\n connections](/vpc/docs/about-propagated-connections#provision) ([Preview](/products#product-launch-stages)) for endpoints that connect to port mapping services.\n- Port mapping services can be published by using either IPv4 or IPv6 ([Preview](/products#product-launch-stages)) addresses. For more information, see [IP version\n translation](/vpc/docs/about-vpc-hosted-services#ip-version-translation).\n\nLimitations\n-----------\n\n- Health checks are not supported on backend services that have port mapping NEGs attached to them. Validation blocks a health check from being configured if the backend service has a port mapping NEG.\n- Private Service Connect port mapping doesn't support connecting multiple service attachments or forwarding rules to the same port mapping backend service.\n- Port mapping services can't be accessed by Private Service Connect backends.\n\nUse load balancing with Private Service Connect port mapping\n------------------------------------------------------------\n\nPrivate Service Connect port mapping forwards traffic based solely\non the client destination port that receives the traffic. If you want to use\nload balancing with Private Service Connect port mapping, you can do\nthe following:\n\n- Ask the consumer to implement load balancing on the consumer side. Software that runs on consumer VMs can send traffic to alternating client destination ports.\n- Create a second service attachment in the producer VPC network that connects to a load balancer instead of a port mapping service. Use the same VMs that are in the port mapping NEG as backends in the load balancer's backend service. The consumer can send traffic that needs to be load balanced to an endpoint that is associated with the second service attachment.\n\nQuotas\n------\n\nFor information about quotas and limits related to\nPrivate Service Connect port mapping, see\n[Quotas and limits](/load-balancing/docs/quotas).\n\nPricing\n-------\n\nPricing for Private Service Connect is described on the\n[VPC pricing page](/vpc/pricing#psc-forwarding-rules).\n\nWhat's next\n-----------\n\n- [About accessing published services through endpoints](/vpc/docs/about-accessing-vpc-hosted-services-endpoints)\n- [Create port mapping services](/vpc/docs/create-port-mapping-service)"]]