TTL and BGP: ebgp-multihop, disable-connected-check and TTL Security Explained
Why eBGP Starts With a TTL of 1
Every IP packet carries a Time To Live field. Each router that forwards the packet lowers it by one, and when it reaches zero the packet is discarded. A packet sent directly to a neighbour on the same link is not forwarded by anyone, so it arrives with exactly the TTL it was sent with. That simple rule is the key to three BGP commands that every CCIE candidate has to keep apart.
Cisco sends eBGP packets with a TTL of 1 by default, and iBGP packets with a TTL of 255. The eBGP default reflects how eBGP is normally built: between two routers on a shared link, run by different organisations. A TTL of 1 means the session cannot accidentally run across other routers, and packets from a remote attacker cannot reach the BGP process by being forwarded to it. iBGP sessions, on the other hand, normally run between loopbacks across the whole AS, so they need to cross many hops.
The default has a second effect that many engineers do not know. IOS does not even try to open a TCP connection to an eBGP neighbour that is not on a directly connected subnet, unless you tell it to. The neighbour sits in Idle or Active, and the output says why.
R1(config)#router bgp 65001
R1(config-router)#neighbor 2.2.2.2 remote-as 65002
R1(config-router)#neighbor 2.2.2.2 update-source Loopback0
R1#show ip bgp neighbors 2.2.2.2 | include BGP state|External
BGP state = Idle
External BGP neighbor not directly connected.
Two routers that want to peer between loopbacks, for example to use two parallel links for one session, now need one of two commands. Choosing the right one depends on whether the neighbour really is several hops away.
ebgp-multihop Versus disable-connected-check
The first option is "#neighbor ebgp-multihop". It raises the outgoing TTL to the value you give, between 1 and 255, and it also lifts the connected check. It is meant for neighbours that really are several router hops away, such as a peer reached through a firewall that routes, or a loopback across a small transit network.
R1(config-router)#neighbor 2.2.2.2 ebgp-multihop 2
R1#show ip bgp neighbors 2.2.2.2 | include BGP state|External|TTL
BGP state = Established, up for 00:00:41
External BGP neighbor may be up to 2 hops away.
Connection is ECN Disabled, Mininum incoming TTL 0, Outgoing TTL 2
One condition catches people out. An eBGP multihop session does not form if the only route the router has to the neighbour is a default route. The neighbour's address has to be reachable through a more specific route, normally a static route or an IGP.
The second option is "#neighbor disable-connected-check". It removes only the connected check, and it keeps the outgoing TTL at 1. That sounds contradictory until you remember that TTL is lowered only by forwarding routers. When R1 sends to R2's loopback across the shared link, R2 receives the packet on its interface and delivers it to its own loopback without forwarding it, so the TTL never reaches zero.
R1(config-router)#no neighbor 2.2.2.2 ebgp-multihop 2
R1(config-router)#neighbor 2.2.2.2 disable-connected-check
R1#show ip bgp neighbors 2.2.2.2 | include BGP state|TTL
BGP state = Established, up for 00:00:18
Connection is ECN Disabled, Mininum incoming TTL 0, Outgoing TTL 1
The session is up with TTL 1. For two directly connected routers peering between loopbacks, this is the cleaner choice. It solves exactly the problem you have, the connected check, and it keeps the protection of TTL 1. Using "#neighbor ebgp-multihop" there works too, but it lets packets travel further than they need to. Many books present multihop as the only way to peer between the loopbacks of directly connected eBGP routers. It is not, and in the CCIE lab the difference is exactly the kind of detail that decides whether a solution meets a task's wording.
TTL Security: Turning the Logic Around
Both commands so far control the TTL a router sends. The third one checks the TTL a router receives, and that makes it a security feature rather than a reachability one. It implements the Generalized TTL Security Mechanism, usually called GTSM.
The idea is clever. An attacker on the Internet can forge a packet's source address, but cannot forge how many routers it crossed. If both neighbours send BGP packets with a TTL of 255, a packet from a directly connected neighbour arrives with 255. Any packet that arrives with less has crossed at least one router, so it did not come from the real neighbour. The router can then drop it before it reaches TCP or BGP.
On Cisco the command is "#neighbor ttl-security hops", with a value from 1 to 254. It sets the outgoing TTL to 255 and accepts only packets whose TTL is at least 255 minus the number of hops you configured.
R1(config-router)#no neighbor 2.2.2.2 disable-connected-check
R1(config-router)#neighbor 2.2.2.2 ttl-security hops 1
R1#show ip bgp neighbors 2.2.2.2 | include BGP state|TTL
BGP state = Established, up for 00:00:09
Connection is ECN Disabled, Mininum incoming TTL 254, Outgoing TTL 255
With one hop allowed, the minimum incoming TTL is 254. That still works for loopback peering across one link, because the neighbour's packet leaves with 255 and is forwarded at most once on the way in.
Four details complete the picture. First, the check is inbound only, so both sides must configure it, or one side will send packets with TTL 1 that the other drops. Second, packets that fail the check are silently discarded, with no ICMP message sent back, so a mismatch looks exactly like a dead neighbour. Third, the command is mutually exclusive with "#neighbor ebgp-multihop": if one is configured, the other is rejected with an error rather than replacing it. Fourth, TTL security is not supported for iBGP neighbours on IOS, because iBGP sessions normally cross many hops anyway.
The three commands now fit together cleanly. Use "#neighbor disable-connected-check" when the neighbour is one link away but you peer between loopbacks. Use "#neighbor ebgp-multihop" when the neighbour really is several routers away. Use "#neighbor ttl-security hops" on every eBGP session where both sides support it, especially at Internet edges, because it turns the TTL from a reachability setting into a filter that a remote attacker cannot pass. When a session refuses to come up after one of these changes, check the "Outgoing TTL" and "Mininum incoming TTL" line on both sides first. It tells you in one line which of the three rules is in force.