Advertising Specific VPC Subnets

Customize the subnets in your VPC network that Cloud Router advertises. The subnets that you advertise will be the only ones visible to on-premises clients. Cloud Router won't dynamically advertise new subnets. If you want to advertise new subnets, you must add them to the advertisement.

See Creating Cloud Routers or Establishing BGP Sessions to specify advertisements when you create a Cloud Router or configure a BGP session.

To specify advertisements on an existing Cloud Router:

Console


  1. Go to the Cloud Router page in the Google Cloud Platform Console.
    Cloud Router list
  2. Select the Cloud Router to update.
  3. In the Cloud Router's detail page, select Edit.
  4. Expand the Advertised routes section.
  5. For the Routes, select Create custom routes.
  6. If Advertise all subnets visible to the the Cloud Router is selected, clear it.
  7. Select Add custom route to add an advertised route.
  8. Configure the route advertisement.
    • Source — Select a predefined list of subnets. Cloud Router lists all subnets available to it, which depends on the VPC network's dynamic routing mode.
    • IP address range — You can modify the advertised subnet IP range. For example, you can specify a more narrow range so that Cloud Router advertises part of the of the subnet.
    • Description — Add a description to help you identify the purpose of this route advertisement.
  9. After you're done adding routes, select Save.

gcloud


Before you begin, record the IP ranges of the subnets to advertise.

  1. Run the update command, using the --set-advertisement-ranges flag to specify the subnet IP ranges to advertise. To append IP ranges to existing advertisements, use the --add-advertisement-ranges flag.

    The following example updates the my-router Cloud Router to advertise the 10.0.0.0/24 and 10.0.10.0/24 subnets. Existing custom advertisements are replaced.

       gcloud compute routers update my-router \
           --set-advertisement-mode custom \
           --set-advertisement-ranges 10.0.0.0/24,10.0.10.0/24
       

    To append IP ranges to an existing advertisement, use the --add-advertisement-ranges flag, as shown in the following example:

       gcloud compute routers update my-router \
           --add-advertisement-ranges 10.0.20.0/24
       

  2. If the advertisement group of your Cloud Router includes all subnets, remove it to prevent Cloud Router from advertising additional subnets. Advertisement groups are Google-defined IP ranges that Cloud Router dynamically advertises. For a list of all advertisements groups, see the set-advertisement-groups flag in the Google SDK documentation.

    1. Run the describe command to check the Cloud Router's advertisements:

         gcloud compute routers describe my-router
         

    2. If the output contains the advertisedGroups field with the ALL_SUBNETS value, remove it. Run the update command with the --remove-advertisement-groups flag:

         gcloud compute routers update my-router \
             --remove-advertisement-groups all_subnets
         

To specify advertisements on an existing BGP session:

Console


  1. Go to the Cloud Router page in the Google Cloud Platform Console.
    Cloud Router list
  2. Select the Cloud Router that contains the BGP session to update.
  3. In the Cloud Router's detail page, select the BGP session to update.
  4. In the BGP session details page, select Edit.
  5. For the Routes, select Create custom routes.
  6. If Advertise all subnets visible to the the Cloud Router is selected, clear it.
  7. Select Add custom route to add an advertised route.
  8. Configure the route advertisement.
    • Source — Select a predefined list of subnets. Cloud Router lists all subnets available to it, which depends on the VPC network's dynamic routing mode.
    • IP address range — You can modify the advertised subnet IP range. For example, you can specify a more narrow range so that Cloud Router advertises part of the of the subnet.
    • Description — Add a description to help you identify the purpose of this route advertisement.
  9. After you're done adding routes, select Save.

gcloud


Before you begin, record the IP ranges of the subnets to advertise.

  1. Run the update-bgp-peer command, using the --set-advertisement-ranges flag to specify the subnet IP ranges to advertise. To append IP ranges to existing advertisements, use the --add-advertisement-ranges flag.

    The following example updates the my-bgp-session BGP session on the my-router Cloud Router to advertise the 10.0.0.0/24 and 10.0.10.0/24 subnets. Existing custom advertisements are replaced.

       gcloud compute routers update-bgp-peer my-router \
           --peer-name my-bgp-session \
           --set-advertisement-mode custom \
           --set-advertisement-ranges 10.0.0.0/24,10.0.10.0/24
       

    To append IP ranges to an existing advertisement, use the --add-advertisement-ranges flag, as shown in the following example:

       gcloud compute routers update-bgp-peer my-router \
           --peer-name my-bgp-session \
           --add-advertisement-ranges 10.0.20.0/24
       

  2. If the advertisement group of your BGP session includes all subnets, remove it to prevent Cloud Router from advertising additional subnets. Advertisement groups are Google-defined IP ranges that Cloud Router dynamically advertises. For a list of all advertisements groups, see the set-advertisement-groups flag in the Google SDK documentation.

    1. Run the describe command to check the Cloud Router's advertisements:

         gcloud compute routers describe my-router
         

    2. If the related BGP session contains the advertisedGroups field with the ALL_SUBNETS value, remove it. Run the update command with the --remove-advertisement-groups flag:

         gcloud compute routers update-bgp-peer my-router \
             --peer-name my-bgp-session \
             --remove-advertisement-groups all_subnets
         

What's next

Was this page helpful? Let us know how we did:

Send feedback about...

Cloud Router