##
BGP
The path-vector protocol that runs the internet. eBGP AD 20 · iBGP AD 200 · TCP 179.
// neighbor states
Idle
Not started / not responding
Connect
TCP session establishing
Active
Attempting to connect
OpenSent
Open message sent
OpenConfirm
Response received
Established
Adjacency up — routes exchanged
// message types
| Open | Start the session, negotiate parameters |
| Update | Advertise / withdraw routes + attributes |
| Keepalive | Maintain the session |
| Notification | Report an error & close |
// attribute categories
| Well-known Mandatory | Supported & propagated — AS-Path, Next-Hop, Origin |
| Well-known Discretionary | Supported; propagation optional — Local Pref, Atomic Aggregate |
| Optional Transitive | Marked partial if unsupported — Aggregator, Community |
| Optional Non-transitive | Dropped if unsupported — MED, Originator ID |
// path attributes (type code)
| 1 | Origin | How it entered BGP (i / e / ?) |
| 2 | AS_Path | ASes traversed — loop prevention & length |
| 3 | Next_Hop | IP used to reach the prefix |
| 4 | MED | Multi-Exit Discriminator — hints entry point (lower wins) |
| 5 | Local_Pref | Preferred exit within the AS (higher wins) |
| 6 | Atomic_Aggregate | Marks a summarized route |
| 7 | Aggregator | AS + router that summarized |
| 8 | Community | Tag for grouping / policy |
| 9 | Originator_ID | Route reflector — route origin |
| 10 | Cluster_List | Route reflector — loop prevention |
// well-known communities
| NO_EXPORT | Don’t advertise outside the AS / confederation |
| NO_ADVERTISE | Don’t advertise to any peer |
| NO_EXPORT_SUBCONFED | Don’t advertise to eBGP peers |
| LOCAL_AS | Keep within the local sub-AS |
| INTERNET | Advertise to everyone (default) |
// origin codes
| IGP (i) | Originated by a network statement / IGP |
| EGP (e) | Learned via legacy EGP (rare) |
| Incomplete (?) | Redistributed from another source |
// eBGP vs iBGP
| eBGP | iBGP |
|---|
| Between | Different ASes | Same AS |
| AD | 20 | 200 |
| TTL | 1 (directly connected) | default IP TTL |
| Next-hop | Set to self | Unchanged (use next-hop-self) |
| AS-Path | Prepends own AS | Unchanged |
| Re-advertise | To iBGP & eBGP peers | Not to other iBGP (needs RR / mesh) |
// path selection order
| 1 | Weight | Highest (Cisco, local to router) |
| 2 | Local Preference | Highest (within the AS) |
| 3 | Self-originated | Prefer locally originated |
| 4 | AS-Path | Shortest path |
| 5 | Origin | IGP > EGP > unknown |
| 6 | MED | Lowest |
| 7 | eBGP / iBGP | Prefer eBGP |
| 8 | IGP metric | Lowest to next hop |
| 9 | eBGP age | Oldest / most stable |
| 10 | Router ID | Lowest (tie-break) |
// facts
- eBGP AD 20 · iBGP AD 200 · TCP 179 · MD5 auth
- Path-vector — chooses by policy, not just hop count
- iBGP needs full mesh, route reflectors or confederations
- Synchronization (legacy): route in the IGP before advertising
// numbers & scaling
- Public ASN 1–64511 · private 64512–65535 · 32-bit ASNs (RFC 6793)
- Timers: Keepalive 60 s · Hold 180 s
- Message header: 16-byte marker + 2-byte length + 1-byte type
- iBGP scaling: route reflectors (RR) or confederations
- RR uses Originator-ID & Cluster-List to break loops
configuration · cisco ios
router bgp 65100
bgp router-id 1.1.1.1
no synchronization
neighbor 172.16.0.2 remote-as 65200
neighbor 172.16.0.2 password S3cret
network 192.168.1.0 mask 255.255.255.0
no auto-summary
verify
show ip bgp summary
show ip bgp neighbors
show ip bgp
clear ip bgp * soft