[[["容易理解","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-05 (世界標準時間)。"],[],[],null,["# Manage BGP timers\n=================\n\nThis page describes the following:\n\n- Cloud Router's BGP timers and their settings, including guidance for configuring the same settings on your on-premises router.\n- Updating the BGP keepalive interval for Cloud Router.\n\nBGP timers and settings\n-----------------------\n\nThe Cloud Router and your on-premises router maintain communication\nby using the following set of timer settings.\n\n### Keepalive timer\n\nBGP systems exchange keepalive messages to determine whether a link or host has\nfailed or is no longer available. In conjunction with the hold timer, the\nkeepalive timer indicates whether a router is reachable to its BGP peer.\n\nThe keepalive timer is the `KEEPALIVE_INTERVAL` between periodic BGP messages\nexchanged between a Cloud Router and its corresponding on-premises peer\nrouter. You can configure this value as described in\n[Update the BGP keepalive interval](#update-bgp-keepalive-interval).\nThe default value is 20 seconds. Google recommends setting the\nkeepalive timers to the same value on your on-premises router and the\nCloud Router.\n\n### Hold timer\n\nThis timer defines the amount of time that a Cloud Router or an\non-premises router must wait, absent a graceful restart notification (TCP `FIN`\nor `RST` packet) or a BGP `CEASE` notification, before moving the BGP session to\nthe `DOWN` state.\n\nRouters negotiate a hold time for each BGP session. The negotiated hold time\nis the lower of the hold timer values configured on Cloud Router and\nthe on-premises router. When the negotiated hold time is reached, and neither a\ngraceful restart notification nor a BGP `CEASE` notification has been received,\na router moves the BGP session to the `DOWN` state and takes the following\nactions:\n\n- Removes all learned routes from the BGP session\n- Stops advertising routes\n\nTo configure the Cloud Router hold timer, update the\nCloud Router BGP keepalive interval. Cloud Router sets the\nvalue of the hold timer to three times the value of the configured keepalive\ninterval. For example, if you set the keepalive timer to 20 seconds,\nthe hold timer is 60 seconds. For more information, see [Update the BGP\nkeepalive interval](#update-bgp-keepalive-interval).\n\n### Graceful restart timer\n\nThis timer defines the amount of time that a router preserves the previous BGP\nsession state following a graceful restart notification (TCP `FIN` or `RST`\npacket) from the peer router.\n\nWhile preserving the previous BGP session state, the router keeps the session's\nlearned routes received from the peer router and continues to advertise its\nroutes to the peer router. If a new BGP session is established while the\nprevious BGP session state is being preserved, there's no interruption to\nconnectivity. However, if a new BGP session isn't established, the session\ntransitions to the `DOWN` state at the end of the graceful restart timer. Once\nin the `DOWN` state, the session's learned routes received from the peer router\nare removed, and the router stops advertising its routes to the peer router.\n\nA router that supports graceful restart advertises a graceful restart timer\nvalue that defines the amount of time that the other router must wait following\na graceful restart notification. Two connected routers might use different\ngraceful restart timer values, and each router is expected to honor the graceful\nrestart timer value of its peer. When establishing a new BGP session, each\nrouter communicates its own graceful restart timer value to the peer router\nthrough the BGP `OPEN` message.\n\nCloud Router supports graceful restart, and the Cloud Router\ngraceful restart timer is set to 120 seconds. Every Cloud Router sends\na graceful restart notification before each [software\nmaintenance](/network-connectivity/docs/router/concepts/how-cloud-router-works#maintenance) event if\nthe peer router also supports graceful restart.\n\nIf you configured your on-premises router with graceful restart, it can also\nsend a graceful restart notification to the Cloud Router during\non-premises router restart or maintenance events. Set your on-premises router's\ngraceful restart timer to a value that is appropriate for your needs.\n\nFor more information about graceful restart, see [RFC\n4724](https://datatracker.ietf.org/doc/html/rfc4724).\n\n### Stalepath timer\n\nThis setting determines how long a router waits before deleting learned routes\nafter it receives an end-of-record (EOR) message from the other router. This\ntimer starts when the BGP session is reinitialized after\na graceful restart, but the prefix in question hasn't been addressed by an\n`UPDATE` message. We recommend setting the stalepath timer to 300 seconds on\nyour on-premises router to match the setting for the Cloud Router.\n\nUpdate the BGP keepalive interval\n---------------------------------\n\nTo modify the BGP keepalive interval on a Cloud Router, follow these\nsteps. \n\n### Console\n\n1. In the Google Cloud console, go to the **Cloud Routers** page.\n\n [Go to Cloud Routers](https://console.cloud.google.com/hybrid/routers/list)\n2. Select the Cloud Router that contains the BGP interval to\n modify.\n\n3. On the **Router details** page, click\n edit**Edit**.\n\n4. Update the **BGP peer keepalive interval**. This value must be an\n integer between 20 and 60 that specifies the number of seconds\n for the interval. The default is 20 seconds.\n\n5. Click **Save**.\n\n### gcloud\n\nRun the `update` command: \n\n```\ngcloud compute routers update ROUTER_NAME \\\n --project=PROJECT_ID \\\n --keepalive-interval=KEEPALIVE_INTERVAL \\\n --region=REGION\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eROUTER_NAME\u003c/var\u003e: the name of the Cloud Router\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the project that contains the Cloud Router\n- \u003cvar translate=\"no\"\u003eKEEPALIVE_INTERVAL\u003c/var\u003e: the interval between BGP\n keepalive messages that are sent to the peer router\n\n This value must be an integer between 20 and 60 that specifies the\n number of seconds for the interval. The default is 20 seconds.\n- \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e: the region where the Cloud Router\n is located\n\nThe output is similar to the following: \n\n```\n Updating router [my-router]...done.\n```\n\n### API\n\nUse the\n[`routers.patch`](/compute/docs/reference/rest/v1/routers/patch)\nmethod to update the `bgp.keepaliveInterval` field: \n\n```\n PATCH https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/routers/ROUTER_NAME\n {\n \"bgp\": {\n \"keepaliveInterval\": KEEPALIVE_INTERVAL\n }\n }\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the project that contains the Cloud Router\n- \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e: the region where the Cloud Router is located\n- \u003cvar translate=\"no\"\u003eROUTER_NAME\u003c/var\u003e: the name of the Cloud Router\n- \u003cvar translate=\"no\"\u003eKEEPALIVE_INTERVAL\u003c/var\u003e: the interval between BGP\n keepalive messages that are sent to the peer router\n\n This value must be an integer between 20 and 60 that specifies the\n number of seconds for the interval. The default is 20 seconds.\n\nWhat's next\n-----------\n\n- To disable a BGP session temporarily or remove it entirely, see [Disable or remove BGP sessions](/network-connectivity/docs/router/how-to/disabling-removing-bgp).\n- To troubleshoot issues when using Cloud Router, see [Troubleshooting](/network-connectivity/docs/router/resources/troubleshooting)."]]