BGP sessions run over plain TCP, and without authentication, anything that can inject or spoof TCP segments toward your BGP session — whether an on-path attacker or, more commonly in practice, a misconfigured or compromised device on a shared segment — can attempt to disrupt or manipulate your routing. MD5 authentication has been the standard defense for BGP sessions for decades. This guide covers configuring MD5 authentication on Cisco routers, verifying it, and the operational considerations around key management and rollover.
What BGP MD5 Authentication Actually Does
BGP MD5 authentication (defined in RFC 2385) adds a TCP MD5 signature option to every segment of the BGP TCP session. Both routers must share the same password (technically used as an MD5 key), and each computes and verifies an MD5 hash over the TCP segment using that shared secret. If the hash doesn’t match, the segment is silently discarded — the receiving router won’t even acknowledge it at the TCP level.
This doesn’t encrypt the BGP session — the actual routing update content is still sent in cleartext over TCP port 179 — but it does prevent trivial TCP session hijacking or injection attacks from a party that doesn’t know the shared secret, and it prevents accidental session establishment between misconfigured neighbors that don’t share the correct key.
Basic MD5 Authentication Configuration
Router(config)# router bgp 65001
Router(config-router)# neighbor 203.0.113.2 remote-as 65002
Router(config-router)# neighbor 203.0.113.2 password MyStr0ngBGPk3y!
Both peers must configure the identical password. The moment you apply or change this on one side, the existing session will reset (if the other side doesn’t have a matching password), since the MD5 signature checks will fail immediately for any in-flight or new segments.
Applying Authentication to Multiple Neighbors via Peer-Group
For consistency across many neighbors sharing the same authentication policy (common in route-reflector or iBGP mesh scenarios):
Router(config)# router bgp 65001
Router(config-router)# neighbor IBGP-PEERS peer-group
Router(config-router)# neighbor IBGP-PEERS password Int3rnalM3sh!Key
Router(config-router)# neighbor 10.0.0.2 peer-group IBGP-PEERS
Router(config-router)# neighbor 10.0.0.3 peer-group IBGP-PEERS
Verifying Authentication Is Active
Router# show ip bgp neighbors 203.0.113.2 | include Authentication
Sample output:
Authentication: Configured, enabled
If a session fails to establish after configuring a password, checking the logs will typically show the session stuck in Idle or Active state repeatedly, since TCP itself can’t complete without matching MD5 signatures:
Router# show ip bgp neighbors 203.0.113.2 | include BGP state
BGP state = Active
Or, more directly, checking system logs:
Router# show logging | include 203.0.113.2
%TCP-6-BADAUTH: No MD5 digest from 203.0.113.2(179) to 203.0.113.1(52341)
This log message is the definitive sign of a password mismatch between the two peers — the local router is receiving segments without a valid (or with an incorrect) MD5 signature.
Changing an Existing Password Without Extended Downtime
Because MD5 mismatches cause immediate TCP-level rejection, changing a password requires coordination. The safest sequence for a planned change during a maintenance window:
- Confirm exact timing with the peer/neighbor administrator (internal team or external partner).
- Apply the new password on both routers as close to simultaneously as operationally possible.
- Monitor
show ip bgp summaryon both sides to confirm the session re-establishes.
There is no graceful “accept either old or new password during transition” mechanism with standard MD5 authentication on Cisco IOS — the change is effectively a hard cutover, which is why coordination matters.
TTL Security (GTSM) as a Complementary Control
While not authentication in the cryptographic sense, BGP TTL Security (Generalized TTL Security Mechanism, GTSM) is commonly deployed alongside MD5 to further reduce attack surface, particularly for eBGP sessions where the peer should always be directly connected:
Router(config-router)# neighbor 203.0.113.2 ttl-security hops 1
This causes the router to only accept BGP packets from that neighbor with a TTL of 254 or 255 (for a single hop), effectively rejecting packets that couldn’t have originated from a directly connected device, since any additional hop would decrement the TTL below the accepted threshold. This is a strong complement to MD5 because it protects against a different threat model — off-path attackers trying to spoof packets from a distance — which is harder for MD5 alone to fully mitigate in certain circumstances, and is much lighter weight computationally than MD5 verification.
Full Example: Secure eBGP Peering
router bgp 65001
neighbor 203.0.113.2 remote-as 65002
neighbor 203.0.113.2 password Str0ngSharedSecret2026!
neighbor 203.0.113.2 ttl-security hops 1
neighbor 203.0.113.2 maximum-prefix 500 80
neighbor 203.0.113.2 prefix-list ACCEPT-FROM-PEER in
neighbor 203.0.113.2 prefix-list MY-BLOCK out
This combines MD5 authentication, TTL security, prefix filtering, and maximum-prefix protection — a layered defense approach rather than relying on any single mechanism.
Password Complexity and Storage Considerations
Cisco IOS stores the BGP neighbor password in the running configuration, and by default it’s stored in a reversible encrypted form (type 7) unless you’ve enabled stronger encryption globally:
Router(config)# service password-encryption
For meaningfully stronger protection of the stored secret, use service password-encryption at minimum, though it’s worth noting Type 7 encryption is a weak, reversible cipher intended mainly to prevent shoulder-surfing rather than serious cryptographic protection — treat the running config itself as sensitive and control access to it accordingly (AAA, restricted enable access, encrypted backups).
On platforms and IOS-XE versions supporting it, use the stronger algorithm-type options where available for locally stored secrets in other authentication contexts (like AAA), and ensure configuration backups and TFTP/SCP transfers of running-config are similarly protected, since a leaked running-config exposes the BGP password regardless of local encryption type.
Common Configuration Mistakes
- Mismatched passwords between peers — the single most common cause of a BGP session refusing to establish after enabling authentication; even a trailing space or case difference will cause failure.
- Changing the password on only one side without coordinating timing, causing an avoidable outage window longer than necessary.
- Assuming MD5 authentication encrypts the BGP session — it does not; routing update contents remain in cleartext. If confidentiality is a requirement, that needs a separate mechanism (like an IPsec tunnel carrying the BGP session).
- Not combining MD5 with TTL security or prefix filtering, relying on a single control when layered defenses are cheap to add and address different threat vectors.
- Forgetting that a password change resets the session immediately, doing this during business hours without a maintenance window when it wasn’t necessary.
Best Practices
- Enable MD5 authentication on every eBGP session as a baseline, not just ones you consider “high risk” — it’s low cost and meaningfully reduces attack surface.
- Combine MD5 with TTL security (GTSM) for eBGP sessions where the neighbor should always be directly connected.
- Use strong, unique passwords per peer rather than reusing the same password across all sessions — a compromise of one peer relationship shouldn’t compromise others.
- Coordinate password changes explicitly with peer administrators, treating it as a planned maintenance activity with a defined rollback plan.
- Protect running-config access and backups since the password is visible (in encrypted form, but recoverable with effort) to anyone with read access to the configuration.
- Log and alert on
%TCP-6-BADAUTHmessages, since a sudden appearance of this log on a previously stable session can indicate either an operational mistake on the peer’s end or a potential security event worth investigating.
Troubleshooting Checklist
show ip bgp neighbors X | include Authentication— confirm authentication is configured and enabled locally.show ip bgp summary— check if the session is stuck inIdle/Activerather thanEstablished.show logging | include BADAUTH— the definitive sign of an MD5 mismatch.- Confirm both sides applied the password change, ideally verified via a call/chat with the peer’s NOC during the change window.
- If TTL security is also enabled, confirm hop count matches actual topology (
ttl-security hops Nwhere N reflects real, expected hop distance). - Use
debug ip tcp transactionssparingly and only in a controlled window, since it can be verbose on busy routers.
FAQs
Does BGP MD5 authentication encrypt routing updates? No. It authenticates the TCP segments carrying the BGP session, preventing unauthorized injection or basic spoofing, but the actual BGP message content remains unencrypted cleartext.
Can I use different passwords for different neighbors on the same router? Yes — authentication is configured per-neighbor (or per-peer-group), so different sessions can and generally should use different shared secrets.
Is MD5 authentication still considered sufficient in 2026, or should I use something stronger? MD5 for BGP TCP authentication remains the widely deployed industry standard and is still considered a meaningful, necessary baseline control, though it’s cryptographically dated compared to modern hash algorithms. Where platforms support it, TCP-AO (TCP Authentication Option, RFC 5925) offers a more modern alternative with stronger cryptographic properties and support for key rollover without a hard cutover — check current platform documentation for TCP-AO support if that stronger posture is a requirement for your environment.
What happens if I forget to apply TTL security correctly on a multi-hop eBGP session (like an eBGP multihop peering)? If the neighbor is legitimately more than one hop away (common in eBGP multihop scenarios such as loopback-to-loopback peering) and you configure ttl-security hops 1, you’ll block the legitimate session since the TTL will have decremented more than expected. Match the hop count to the actual topology, or use neighbor X ebgp-multihop N appropriately alongside TTL security settings that reflect the real path length.
Summary
BGP MD5 authentication is a foundational, low-effort control that every eBGP (and typically iBGP) session should have enabled — it prevents casual TCP session injection and accidental peering mismatches, at the cost of requiring coordinated password changes between peers. Layering it with TTL security and standard prefix/AS-path filtering gives you defense in depth against distinct threat vectors: MD5 protects session integrity, TTL security protects against off-path spoofing, and filtering protects against bad or malicious routing information even from an authenticated, legitimate peer. None of these controls alone is sufficient, but together they form the standard, expected security posture for any production BGP deployment.
References
- BGP Support for TTL Security Check: https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/iproute_bgp/configuration/xe-16/irg-xe-16-book/irg-ttl-security.html
- Configuring BGP Neighbor Authentication: https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/iproute_bgp/configuration/xe-16/irg-xe-16-book.html
- RFC 2385 – Protection of BGP Sessions via TCP MD5 Signature Option: https://datatracker.ietf.org/doc/html/rfc2385
- RFC 5925 – The TCP Authentication Option: https://datatracker.ietf.org/doc/html/rfc5925