[[["容易理解","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-08 (世界標準時間)。"],[],[],null,["# Apply BGP route policies\n========================\n\nThis guide describes how to apply BGP route policies in Cloud Router.\n\nAdd a BGP route policy to a BGP peer\n------------------------------------\n\nAdding a BGP route policy to a BGP peer replaces *all* existing BGP policies for\nthe peer. For example, `--import-policies=` removes all existing import policies\nfor the listed BGP peer, and\n`--import-policies=my-import-policy1,my-import-policy2` replaces the existing\nimport policy chain defined for the peer.\n\nTo add a BGP route policy to a BGP peer, run the following command: \n\n```\ngcloud compute routers add-bgp-peer ROUTER_NAME \\\n --peer-name=PEER_NAME \\\n --import-policies=IMPORT_POLICIES \\\n --export-policies=EXPORT_POLICIES\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eROUTER_NAME\u003c/var\u003e: the name of your Cloud Router\n- \u003cvar translate=\"no\"\u003ePEER_NAME\u003c/var\u003e: the name of the BGP peer that the policies apply to\n- \u003cvar translate=\"no\"\u003eIMPORT_POLICIES\u003c/var\u003e: a comma-separated list of import policies to apply to the named peer\n- \u003cvar translate=\"no\"\u003eEXPORT_POLICIES\u003c/var\u003e: a comma-separated list of export policies to apply to the named peer\n\nThe command fails if any of the following are true:\n\n- `--peer-name=` doesn't list an existing peer\n- `--import-policy=` doesn't list an existing import policy\n- `--export-policy=` doesn't list an existing export policy\n\nUpdate a BGP route policy to a BGP peer\n---------------------------------------\n\nUpdating a BGP route policy to a BGP peer replaces *all* existing BGP policies\nfor the peer. For example, `--import-policies=` removes all existing import\npolicies for the listed BGP peer, and\n`--import-policies=my-import-policy1,my-import-policy2` replaces the existing\nimport policy chain defined for the peer.\n\nTo update a BGP route policy to a BGP peer, run the following command: \n\n```\ngcloud compute routers update-bgp-peer ROUTER_NAME \\\n --peer-name=PEER_NAME \\\n --import-policies=IMPORT_POLICIES \\\n --export-policies=EXPORT_POLICIES\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eROUTER_NAME\u003c/var\u003e: the name of your Cloud Router\n- \u003cvar translate=\"no\"\u003ePEER_NAME\u003c/var\u003e: the name of the BGP peer that the policies apply to\n- \u003cvar translate=\"no\"\u003eIMPORT_POLICIES\u003c/var\u003e: a comma-separated list of import policies to apply to the named peer\n- \u003cvar translate=\"no\"\u003eEXPORT_POLICIES\u003c/var\u003e: a comma-separated list of export policies to apply to the named peer\n\nThe command fails if any of the following are true:\n\n- `--peer-name=` doesn't list an existing peer\n- `--import-policy=` doesn't list an existing import policy\n- `--export-policy=` doesn't list an existing export policy\n\nDownload a BGP route policy\n---------------------------\n\nTo download a BGP route policy to your computer, run the following command: \n\n```\ngcloud compute routers download-route-policy ROUTER_NAME \\\n --policy-name=BGP_ROUTE_POLICY_NAME \\\n --file-name=FILE_NAME\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eROUTER_NAME\u003c/var\u003e: the name of your Cloud Router\n- \u003cvar translate=\"no\"\u003eBGP_ROUTE_POLICY_NAME\u003c/var\u003e: the name of the BGP route policy that you want to export\n- \u003cvar translate=\"no\"\u003eFILE_NAME\u003c/var\u003e: the name of the file to download the route policy to\n\nThe output defaults to a YAML file. To export a JSON file, run the following\ncommand: \n\n```\ngcloud compute routers download-route-policy ROUTER_NAME \\\n --policy-name=BGP_ROUTE_POLICY_NAME \\\n --file-name=FILE_NAME \\\n --format=json\n```\n\nDisplay a BGP route policy\n--------------------------\n\nTo display a BGP route policy, run the following command: \n\n```\ngcloud compute routers get-route-policy ROUTER_NAME \\\n --policy-name=BGP_ROUTE_POLICY_NAME\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eROUTER_NAME\u003c/var\u003e: the name of your Cloud Router\n- \u003cvar translate=\"no\"\u003eBGP_ROUTE_POLICY_NAME\u003c/var\u003e: the name of the BGP route policy that you want to export\n\nThe output defaults to a YAML file. To export a JSON file, run the following\ncommand: \n\n```\ngcloud compute routers get-route-policy ROUTER_NAME \\\n --policy-name=BGP_ROUTE_POLICY_NAME \\\n --format=json\n```\n\nWhat's next\n-----------\n\n- [Create BGP route policies](/network-connectivity/docs/router/how-to/bgp-route-policies/create-policies)"]]