BGP Graceful Shutdown (RFC 8326): Safe Maintenance Guide
BGP graceful shutdown (RFC 8326) lets you drain traffic from a BGP session before you take it down. You tag your routes with the well-known GRACEFUL_SHUTDOWN community (65535:0), and neighbors that honor it lower the LOCAL_PREF of those routes so they move traffic to a backup path while the session is still up.
Without it, you shut the session and every flow on that path is blackholed until BGP reconverges, which can take seconds to minutes. This guide covers how the mechanism works, working configs for Cisco, Juniper, BIRD and FRR, a pre-maintenance checklist, and how to drain a GRE+BGP tunnel to a DDoS scrubbing edge without dropping customer traffic.
How RFC 8326 works
The community is 65535:0 (0xFFFF0000). The flow is:
- Before maintenance, you re-announce your routes on the session with
65535:0attached. - The neighbor's inbound policy matches the community and sets a very low LOCAL_PREF (the RFC suggests 0).
- If the neighbor has another path to your prefixes, it prefers that one. Traffic toward you shifts away from the session you are about to touch.
- Once traffic is near zero, you shut down the session.
The mechanism has two directions, and you have to handle both:
| Direction | What you control | How |
|---|---|---|
| Traffic to you (inbound) | Your announcements | Tag with 65535:0, prepend as fallback |
| Traffic from you (outbound) | Your own inbound policy | Set LOCAL_PREF low on routes from that peer |
Because the community is well-known, it propagates by default. Some networks strip communities, and some never implemented the receiver logic. Treat 65535:0 as a request, not a guarantee, and verify with traffic counters.
Build the receiver policy first
Do this on every session before you need it, so you also honor the community when your neighbors drain toward you. Keep your normal bogon, prefix-length and max-prefix filters ahead of this term.
Cisco IOS-XE
ip community-list standard GSHUT permit 65535:0
!
route-map TRANSIT-A-IN permit 5
match community GSHUT
set local-preference 0
route-map TRANSIT-A-IN permit 10
set local-preference 200
!
router bgp 64500
address-family ipv4
neighbor 192.0.2.1 send-community both
neighbor 192.0.2.1 route-map TRANSIT-A-IN in
send-community is mandatory. Forgetting it is the most common reason tagging "does nothing" on Cisco. IOS-XE also has a built-in neighbor ... shutdown graceful option. Check your release's documentation for the exact syntax before relying on it.
Juniper Junos
set policy-options community GSHUT members 65535:0
set policy-options policy-statement TRANSIT-A-IN term gshut from community GSHUT
set policy-options policy-statement TRANSIT-A-IN term gshut then local-preference 0
set policy-options policy-statement TRANSIT-A-IN term gshut then accept
insert policy-options policy-statement TRANSIT-A-IN term gshut before term normal
Newer Junos releases also have a graceful-shutdown stanza under BGP with sender and receiver behavior. If your version has it, test it in a lab and compare it with explicit policy.
BIRD 2
filter transit_a_in {
# bogon and length filters first
if (65535, 0) ~ bgp_community then {
bgp_local_pref = 0;
accept;
}
bgp_local_pref = 200;
accept;
}
FRR
bgp community-list standard GSHUT seq 5 permit 65535:0
!
route-map TRANSIT-A-IN permit 5
match community GSHUT
set local-preference 0
route-map TRANSIT-A-IN permit 10
set local-preference 200
FRR also has a global bgp graceful-shutdown command that drains the whole instance. Read the docs for what it changes on eBGP and iBGP sessions before using it on a production router.
Send the community and drain
On the session you are about to maintain, change the outbound policy to tag your prefixes. Add a prepend as a fallback for peers that ignore the community.
Cisco IOS-XE
route-map TRANSIT-A-OUT permit 10
match ip address prefix-list OUR-PREFIXES
set community 65535:0 additive
set as-path prepend 64500 64500 64500
Then run clear ip bgp 192.0.2.1 soft out.
Junos
set policy-options policy-statement TRANSIT-A-OUT-DRAIN term ours from prefix-list OUR-PREFIXES
set policy-options policy-statement TRANSIT-A-OUT-DRAIN term ours then community add GSHUT
set policy-options policy-statement TRANSIT-A-OUT-DRAIN term ours then as-path-prepend "64500 64500 64500"
set policy-options policy-statement TRANSIT-A-OUT-DRAIN term ours then accept
set policy-options policy-statement TRANSIT-A-OUT-DRAIN term rest then reject
BIRD 2
filter transit_a_out_drain {
if net ~ [ 198.51.100.0/24 ] then {
bgp_community.add((65535, 0));
bgp_path.prepend(64500);
bgp_path.prepend(64500);
accept;
}
reject;
}
Apply it with birdc reload out transit_a.
FRR
route-map TRANSIT-A-OUT permit 10
match ip address prefix-list OUR-PREFIXES
set community 65535:0 additive
set as-path prepend 64500 64500 64500
Then run clear bgp ipv4 unicast 192.0.2.1 soft out.
For outbound traffic, lower LOCAL_PREF on routes learned from that peer (set the inbound policy value to 0 or below your other paths). That moves your egress to another provider independently of what the neighbor does.
Pre-maintenance checklist
- Confirm a working alternate path exists for every prefix. If the session is your only path, draining achieves nothing.
- Check that the backup has capacity for the full load. Look at the 95th percentile, not the average.
- Verify the neighbor honors 65535:0 (documentation, looking glass, or ask their NOC). Otherwise rely on prepends or ask them to lower preference.
- Confirm
send-communityand outbound policy are applied on the session. - Pause or review automation that touches this session (RTBH, FlowSpec, diversion announcements). Do not start maintenance during an active attack.
- Announce the window to the peer, and send an RFC 8203 shutdown message if your platform supports it.
- Record baseline bps/pps per interface from your flow collector so you can see the shift.
- Prepare a rollback: remove the community and prepend and soft-reset out.
Verify before you shut down
Do not shut down on a timer alone. Wait until the interface counters and your flow data show the session carrying close to zero traffic. Some residual traffic is normal from networks with sticky or static routes. Allow time for MRAI timers and upstream propagation. Ten to fifteen minutes is common on transit, and IX peers can take longer.
Check the receiver's view with a looking glass if one exists:
show ip bgp 198.51.100.0/24 # Cisco: look for LOCAL_PREF 0 / community 65535:0 on the neighbor
show route 198.51.100.0/24 detail # Junos
Draining a GRE+BGP tunnel to a scrubbing edge
A DDoS tunnel is a GRE tunnel with a BGP session inside it. In a setup like NixGuard Edge, your prefixes are announced from the scrubbing edge and clean traffic comes back through the tunnel. Maintenance on the tunnel endpoint (router reload, upgrade, tunnel source change) must not strand that traffic.
The safe order:
- Bring up the second path first. That can be a second GRE tunnel to another endpoint on a different router, or a direct transit path if you run on-demand protection. Verify its BGP session is Established and its routes are received. Confirm the MTU and MSS clamping match the primary (see our GRE MTU and MSS guide).
- Lower preference on the primary tunnel. Raise the metric or lower LOCAL_PREF on the routes you use for return traffic over the primary. Then apply the drain policy toward the edge as agreed with your provider. Not every provider honors 65535:0 on tunnel sessions, so confirm how the edge handles it.
- Watch the tunnel interface. Use your flow collector or interface counters to confirm that traffic moves to the second path and the primary drops to near zero.
- Check stateful devices. If you run a stateful firewall or a SYN proxy, make sure the new path does not produce asymmetric flows that your state table will drop.
- Shut down BGP inside the tunnel, then the GRE interface. Do your maintenance.
- Restore in reverse. Bring up GRE, wait for BGP Established, verify routes, then remove the drain policy. Watch for flapping before declaring done.
For always-on protection, plan a window with your provider. For on-demand protection, the simplest rule is to avoid starting diversion while the tunnel is being worked on, and to hold automated mitigation until the tunnel is back.
Common mistakes
- No
send-community. The tag never leaves the router. - Inbound policy order. A broad
local-preference 200term placed above the GSHUT match overrides it. - Draining a single-homed session. The routes are still the only path, so traffic stays.
- Shutting down too early. The session drops while flows still arrive.
- Ignoring the outbound side. You drain inbound but keep sending traffic out the same link.
- Forgetting that automation keeps running. An RTBH or FlowSpec announcement can fire into a session you are about to disable.
- Not removing the drain policy afterward. You then run at LOCAL_PREF 0 or with prepends indefinitely.
Monitoring the drain
A drain is only as good as your visibility. Per-interface and per-prefix bps/pps from NetFlow, IPFIX or sFlow show which path carries traffic before and after you apply the policy. NixMon analyzes flow data for DDoS detection and can serve as a collector for this check. If you want protection that arrives over a GRE+BGP tunnel for networks with their own ASN and at least one /24, see NixGuard Edge. You can try the platform with the 15-day free trial, with no credit card.
Frequently asked questions
What is the BGP GRACEFUL_SHUTDOWN community?
It is the well-known community 65535:0 defined in RFC 8326. A router attaches it to routes before maintenance, and neighbors that support it lower the LOCAL_PREF of those routes so they prefer another path while the session is still up.
Does every peer honor 65535:0?
No. Many transit providers and some IX participants do, but others strip communities or never implemented the receiver policy. Check their documentation, and use AS-path prepending as a fallback. Confirm the shift with interface counters or flow data.
How long should I wait before shutting down the session?
Wait until traffic on the session is close to zero rather than using a fixed timer. Ten to fifteen minutes is common on transit, and longer on IX sessions. Residual traffic from static routes or sticky policies can remain.
Can I use graceful shutdown on a GRE+BGP DDoS tunnel?
Yes, if your provider honors the community on that session. The more important step is having a second path ready, such as another tunnel or a direct transit path. Shift preference to it, confirm traffic has left the primary tunnel, then shut down BGP and GRE.