Cloud Service Mesh 轉送規則的 IP 位址不需要與虛擬私有雲 (VPC) 網路中子網路的 IP 位址範圍相符。對於指定的 VPC 網路、IP 位址和連接埠,您只能擁有一個內部、自行管理的轉送規則。
舉例來說,在同一個 VPC 網路中,您無法建立兩個使用 0.0.0.0 IP 位址和 80 通訊埠的轉送規則。
IPAddress 與目標 gRPC Proxy
轉送規則會參照目標 gRPC Proxy,其中 validateForProxyless 欄位設為 TRUE,其 IP 位址設為 0.0.0.0。
使用 xds 配置的 gRPC 用戶端不會執行 DNS 查詢,以解析管道 URI 中的主機名稱。相反地,這類用戶端會傳送 Listener Discovery Service (LDS) 要求至 Cloud Service Mesh,藉此解析目標 URI 中的 hostname[:port]。不涉及 DNS 查詢,也不需要主機名稱的 DNS 項目。
因此,Cloud Service Mesh 會使用 URI 中指定的 0.0.0.0 IP 位址和通訊埠 (預設為 80) 來查詢轉送規則。接著,Cloud Service Mesh 會在轉寄規則參照的目標 Proxy 網址對應中,尋找相符的主機規則。
target
✔
這項轉送規則將流量導向的目標 Proxy。Cloud Service Mesh 支援 target-http-proxy、target-https-proxy 和 target-grpc-proxy。
使用 Google Cloud 控制台設定轉送規則時,系統會自動設定目標 Proxy。使用 Google Cloud CLI 或 API 時,必須先建立目標 Proxy,才能建立轉送規則。您可以為特定 Proxy 使用多個轉送規則。
IPProtocol
✔
這個轉送規則相符的通訊協定類型。唯一支援的值為 TCP。
loadBalancingScheme
✔
指定轉送規則的使用方式。Cloud Service Mesh 的有效值為 INTERNAL_SELF_MANAGED。
[[["容易理解","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-04 (世界標準時間)。"],[],[],null,["# Forwarding rules for Cloud Service Mesh\n=======================================\n\n| **Note:** This guide only supports Cloud Service Mesh with Google Cloud APIs and does not support Istio APIs. For more information see, [Cloud Service Mesh overview](/service-mesh/docs/overview).\n\nThis document applies only to Cloud Service Mesh with the load balancing APIs. We\nstrongly recommend that you use the\n[service routing APIs](/service-mesh/docs/service-routing/service-routing-overview)\nto deploy Cloud Service Mesh.\n\nCloud Service Mesh uses the forwarding rule to determine the target proxy to\nwhich traffic in the mesh is routed.\n\nEach forwarding rule provides a single global IPv4 address for a service. You\ncan use that address to create internal DNS records for your service\n(for example, by using a\n[Cloud DNS managed private zone](/dns/docs/zones#create-private-zone)).\nMetadata filters in the forwarding rule specify the criteria for which an\nxDS-compliant sidecar proxy receives the configuration.\n| **Note:** This page only discusses forwarding rules in the context of Cloud Service Mesh. Forwarding rules are also used to provide forwarding information in the control plane for [protocol forwarding](/load-balancing/docs/protocol-forwarding), [Classic VPN gateways](/network-connectivity/docs/vpn/concepts/overview#classic-vpn), and [Google Cloud load balancers](/load-balancing/docs/using-forwarding-rules). For a more comprehensive overview of forwarding rules, see the [Cloud Load Balancing forwarding rules overview](/load-balancing/docs/forwarding-rule-concepts).\n\nFor the Cloud Service Mesh control plane, the internal, self-managed, and\nglobal forwarding rule routes traffic by IP address, port, and protocol to a\ntarget proxy. The target proxy points to a URL map that contains rules that\ndetermine the destination of the traffic. The URL map also specifies the default\nbackend service. This backend service specifies a health check and determines\nthe appropriate backend, such as a managed instance group (MIG) that contains\nvirtual machine (VM) instances or a\n[network endpoint group (NEG)](/kubernetes-engine/docs/how-to/standalone-neg)\nthat contains Google Kubernetes Engine (GKE) backend Pods.\n\nThe following diagram shows how a forwarding rule fits into the Cloud Service Mesh\narchitecture.\n[](/static/service-mesh/docs/images/td-forwarding-rule.svg) Cloud Service Mesh forwarding rule highlighted (click to enlarge)\n\nForwarding rule properties\n--------------------------\n\nA forwarding rule resource contains the following properties that apply to\nCloud Service Mesh. The forwarding rule handles traffic that matches the\ndestination IP address, protocol, and port number.\n\nA `0.0.0.0` IP address in a forwarding rule is one of the options when\nusing Cloud Service Mesh. A `0.0.0.0` IP address means any IP address.\n\n- With a proxy deployment, a `0.0.0.0` IP address lets a proxy match any\n incoming traffic if no other specific match is found.\n\n- With a proxyless deployment, a `0.0.0.0` IP address provides a way to specify\n that an IP address is not required. More details follow about using\n `0.0.0.0` IP addresses with a target gRPC proxy.\n\nThe following table describes forwarding rule properties in more detail.\n\nAdd a global forwarding rule\n----------------------------\n\nTo learn how to configure a forwarding rule within the overall\nCloud Service Mesh setup with the load balancing APIS, see the following:\n\n- [Set up Cloud Service Mesh for Compute Engine VMs with automatic Envoy deployment](/service-mesh/legacy/load-balancing-apis/set-up-gce-vms-auto)\n- [Set up Cloud Service Mesh for Compute Engine VMs with manual Envoy deployment](/service-mesh/legacy/load-balancing-apis/set-up-gce-vms)\n- [Set up Cloud Service Mesh for GKE Pods with automatic Envoy injection](/service-mesh/legacy/load-balancing-apis/set-up-gke-pods-auto)\n- [Set up Cloud Service Mesh for GKE Pods with manual Envoy injection](/service-mesh/legacy/load-balancing-apis/set-up-gke-pods)\n- [Set up Cloud Service Mesh for Compute Engine VMs and proxyless gRPC services](/service-mesh/legacy/load-balancing-apis/set-up-proxyless-gce)\n- [Set up Cloud Service Mesh for GKE Pods and proxyless gRPC services](/service-mesh/legacy/load-balancing-apis/set-up-proxyless-gke)\n\nWhat's next\n-----------\n\n- To use metadata filters to control which sidecar proxies receive the configuration attached to the forwarding rule, see [Setting up config filtering based on `MetadataFilter` match](/service-mesh/legacy/load-balancing-apis/configure-advanced-traffic-management#config-filtering-metadata).\n- To route traffic, see [Cloud Service Mesh routing rule maps overview](/service-mesh/legacy/load-balancing-apis/routing-rule-maps).\n- To learn more about Cloud Service Mesh, see the [Cloud Service Mesh overview](/service-mesh/docs/overview)."]]