Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Route basate su policy
Questo documento fornisce una panoramica del routing basato su policy.
Le route basate su criteri consentono di selezionare un hop successivo in base a piรน di un indirizzo IP di destinazione di un pacchetto. Puoi abbinare il traffico anche in base al protocollo e all'indirizzo IP di origine. Il traffico corrispondente viene reindirizzato a un bilanciatore del carico di rete passthrough interno. In questo modo puoi inserire appliance come firewall nel percorso del traffico di rete.
Specifiche
Quando crei una route basata su policy, selezioni le risorse a cui si applica la route basata su policy. La route puรฒ essere applicata a:
Tutte le istanze VM, i collegamenti VLAN Cloud Interconnect e
i tunnel Cloud VPN che si trovano nella stessa rete VPC
della route
Solo le istanze VM che si trovano nella stessa rete VPC
della route e identificate dai tag di rete
Solo i collegamenti VLAN che si trovano in una regione specifica della stessa rete VPC della route. Non puoi creare una route basata su criteri che si applichi solo a un singolo collegamento VLAN o tunnel Cloud VPN
L'hop successivo di una route basata su criteri deve essere un bilanciatore del carico di rete passthrough interno valido. Questo bilanciatore del carico di rete pass-through interno deve
trovarsi nella stessa rete VPC della route basata su policy o
in una rete VPC connessa alla rete VPC della route tramite
peering di rete VPC.
Le istanze VM di backend del bilanciatore del carico di rete passthrough interno dell'hop successivo devono avere l'IP
forwarding abilitato.
Le route basate su criteri vengono valutate prima delle route di subnet, delle route statiche e
delle route dinamiche, ma dopo i percorsi di routing
speciali. Per saperne di piรน, consulta il passaggio
Route basate su policy nell'ordine
di routing.
Se due o piรน route basate su criteri hanno la stessa prioritร e le caratteristiche di un pacchetto corrispondono ad almeno due di queste route basate su criteri, Google Cloud
seleziona una singola route basata su criteri utilizzando un algoritmo interno. La
route basata su criteri selezionata potrebbe non essere la corrispondenza piรน specifica per le
caratteristiche del pacchetto perchรฉ le route basate su criteri non utilizzano la corrispondenza
del prefisso piรน lungo. Assicurati che tutte le route basate su policy nella stessa rete VPC abbiano prioritร univoche.
Una route basata su policy puรฒ essere applicata al traffico IPv4 o IPv6.
Puoi creare una singola regola per il traffico unidirezionale o piรน regole per gestire
il traffico bidirezionale.
Limitazioni
Le route basate su criteri non vengono scambiate tra le reti VPC connesse tramite peering di rete VPC.
Le route basate su policy non supportano la corrispondenza del traffico in base alla porta.
Non รจ possibile aggiornare una route basata su policy dopo la sua creazione. Se
vuoi aggiornare un percorso, eliminalo
e poi creane uno nuovo.
La regola di forwarding del bilanciatore del carico di rete passthrough interno deve avere un indirizzo IP dedicato che non venga utilizzato da nessun altro bilanciatore del carico di rete passthrough interno. L'utilizzo di un indirizzo IP condiviso (scopo
dell'indirizzo IP impostato su SHARED_LOADBALANCER_VIP) non รจ supportato.
Le route basate su criteri possono interferire con la comunicazione tra il piano di controllo GKE e i nodi. Per maggiori informazioni, consulta
Utilizzare route basate su criteri con GKE.
Le route basate su criteri non possono instradare i pacchetti verso endpoint o backend Private Service Connect.
Solo i collegamenti VLAN che utilizzano Dataplane v2
possono utilizzare route basate su policy.
Per esaminare il collegamento VLAN e verificare la versione utilizzata, consulta le istruzioni per
Dedicated Interconnect
o Partner Interconnect.
Salto di altre route basate su policy
Puoi creare una route basata su policy che ignora altre route basate su policy utilizzando Google Cloud CLI o inviando una richiesta API. Per
gcloud CLI, utilizza il
flag --next-hop-other-routes=DEFAULT_ROUTING. Per una richiesta API,
includi "nextHopOtherRoutes": "DEFAULT_ROUTING" nel corpo della richiesta.
Se una route basata su criteri di questo tipo corrisponde alle caratteristiche di un pacchetto e ha una prioritร superiore rispetto ad altre route basate su criteri corrispondenti, Google Cloudignora le altre route basate su criteri e passa al passaggio destinazione piรน specifica dell'ordine di routing VPC.
Ad esempio, considera una route basata su policy che utilizza un bilanciatore del carico di rete passthrough interno come hop successivo. Questa route basata su criteri ha un intervallo di origine
0.0.0.0/0 e un tag di rete compute-vm.
Per ignorare la valutazione della prima route basata su criteri quando le origini dei pacchetti corrispondono a un intervallo di indirizzi IP specifico, crea una route basata su criteri a prioritร piรน alta configurata per ignorare altre route basate su criteri. Imposta l'intervallo di indirizzi IP di origine per questa route basata su policy con prioritร piรน elevata sull'intervallo di indirizzi IP di origine dei sistemi che devono ignorare il routing basato su criteri.
Quota
Esiste un limite al numero di route basate su policy che puoi creare in un singolo progetto. Per saperne di piรน, consulta le quote per progetto nella documentazione di VPC.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema รจ stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-05 UTC."],[],[],null,["# Policy-based routes\n===================\n\nThis document provides an overview of Policy-based Routing.\n\nPolicy-based routes let you select a next hop based on more than a packet's\ndestination IP address. You can match traffic by protocol and source IP address\nas well. Matching traffic is redirected to an internal passthrough Network Load Balancer. This can help\nyou insert appliances such as firewalls into the path of network traffic.\n\nSpecifications\n--------------\n\n- When you [create a policy-based\n route](/vpc/docs/use-policy-based-routes#create), you select which resources the policy-based route applies to. The route can apply to:\n - All VM instances, Cloud Interconnect VLAN attachments, and Cloud VPN tunnels that are in the same VPC network as the route\n - Only VM instances that are in the same VPC network as the route and identified by [network\n tags](/vpc/docs/add-remove-network-tags)\n - Only VLAN attachments that are in a specific region of the same VPC network as the route. You can't create a policy-based route that only applies to a single VLAN attachment or Cloud VPN tunnel\n- The next hop of a policy-based route must be a valid [internal passthrough Network Load Balancer](/load-balancing/docs/internal). This internal passthrough Network Load Balancer must either be in the same VPC network as the policy-based route or in a VPC network that is connected to the route's VPC network through [VPC Network Peering](/vpc/docs/vpc-peering).\n- The backend VM instances of the next hop internal passthrough Network Load Balancer must have [IP\n forwarding](/vpc/docs/using-routes#create-vm-canipforward) enabled.\n- Policy-based routes are evaluated before subnet routes, static routes, and dynamic routes, but after [special routing\n paths](/vpc/docs/routes#special_return_paths). For more information, see the [Policy-based routes](/vpc/docs/routes#check-for-pbrs) step in the routing order.\n- If two or more policy-based routes have the same priority, and a packet's characteristics match at least two of those policy-based routes, Google Cloud selects a single policy-based route by using an internal algorithm. The selected policy-based route might not be the most specific match for the packet's characteristics because policy-based routes don't use longest-prefix matching. Make sure that all policy-based routes in the same VPC network have unique priorities.\n- A policy-based route can apply to either IPv4 or IPv6 traffic.\n- You can create a single rule for one-way traffic or multiple rules to handle bidirectional traffic.\n\nLimitations\n-----------\n\n- Policy-based routes are not exchanged between VPC networks that are connected through [VPC Network Peering](/vpc/docs/vpc-peering).\n- Policy-based routes are not exchanged between [Network Connectivity Center spokes and hubs](/network-connectivity/docs/network-connectivity-center/concepts/vpc-spokes-overview).\n- Policy-based routes don't support matching traffic based on port.\n- It is not possible to update a policy-based route after it is created. If you want to update a route, [delete the route](/vpc/docs/use-policy-based-routes#delete) and then create a new one.\n- The internal passthrough Network Load Balancer forwarding rule must have a dedicated IP address that's not used by any other internal passthrough Network Load Balancer. Using a shared IP address (IP address purpose set to `SHARED_LOADBALANCER_VIP`) is not supported.\n- Policy-based routes can interfere with communication between the GKE control plane and nodes. For more information, see [Use policy-based routes with GKE](/vpc/docs/use-policy-based-routes#pbr-with-gke).\n- Policy-based routes can't route packets to Private Service Connect endpoints or backends.\n - For information about using policy-based routes in VPC networks with endpoints or backends that access published services, see [Policy-based routes and Private Service Connect for published services](/vpc/docs/use-policy-based-routes#pbr-with-psc).\n - For information about using policy-based routes in VPC networks with endpoints or backends that access Google APIs and services, see [Policy-based routes and accessing Google APIs and services](/vpc/docs/use-policy-based-routes#pbr-with-pga-psc-apis).\n- Only VLAN attachments that use [Dataplane v2](/network-connectivity/docs/interconnect/concepts/terminology#dataplaneVersion) can use policy-based routes. To inspect your VLAN attachment to check what version it uses, see the instructions for [Dedicated Interconnect](/network-connectivity/docs/interconnect/how-to/dedicated/viewing-vlans#dataplane) or [Partner Interconnect](/network-connectivity/docs/interconnect/how-to/partner/viewing-vlans#dataplane).\n\nSkipping other policy-based routes\n----------------------------------\n\nYou can create a policy-based route that skips other policy-based\nroutes by using the Google Cloud CLI or sending an API request. For the\ngcloud CLI, use the\n`--next-hop-other-routes=DEFAULT_ROUTING` flag. For an API request,\ninclude `\"nextHopOtherRoutes\": \"DEFAULT_ROUTING\"` with the request body.\n\nIf a policy-based\nroute of this type matches a packet's characteristics and has\na higher priority than other matching policy-based routes, Google Cloud\nignores the other policy-based routes and proceeds to the *most specific\ndestination* step of the\n[VPC routing order](/vpc/docs/routes#routeselection).\n\nFor example, consider a policy-based route that uses a next hop\ninternal passthrough Network Load Balancer. This policy-based route has a source\nrange of `0.0.0.0/0` and a network tag of `compute-vm`.\n\nTo skip evaluation of the first policy-based route when packet sources match\na specific IP address range, create a higher-priority policy-based route that\nis configured to skip other policy-based routes. Set the source IP\naddress range for this higher-priority policy-based route to the\nsource IP address range of the systems that need to skip policy-based routing.\n\nQuota\n-----\n\nThere is a limit for how many policy-based routes you can create in a single\nproject. For more information, see the per-project [quotas](/vpc/docs/quota#policy-based-routes-quota)\nin the VPC documentation."]]