BGP · Topic 2 of 7

BGP Transport, Packet Types, iBGP and eBGP

Learn how BGP runs over TCP port 179, the four message types, the session states, and the key behavioural differences between iBGP and eBGP peers.

  • 5 min
  • Includes a diagram
In a nutshell
  • BGP uses TCP port 179.
  • The message types are OPEN, UPDATE, KEEPALIVE and NOTIFICATION.
  • The session is fully working only in the Established state.

What it is

BGP runs over TCP and uses a small set of messages to build sessions and exchange routes.

Because TCP gives reliable delivery, BGP needs no routing protocol of its own to ship updates. A session is simply a TCP connection between two configured peers.

A peer is eBGP when it sits in a different AS and iBGP when it sits in the same AS. The two behave differently in several ways that the exam tests.

Router AAS 65001TCP port 179, OPENRouter BAS 100Router BAS 100OPEN, KEEPALIVERouter AAS 65001UPDATE with prefixesRouter BAS 100

How it works

A session moves through states, then peers trade UPDATE messages and watch each other with KEEPALIVE messages.

Transport

BGP uses TCP port 179. One router opens the connection and the other accepts it. If a firewall on either router drops that port, the session never forms.

This also means the peers must be able to reach each other by IP. For directly connected peers that is automatic. For others, a route must exist first.

The four message types

MessagePurpose
OPENStarts the session. Carries the AS number, router ID and proposed hold time.
UPDATEAnnounces new prefixes with their attributes, or withdraws old ones.
KEEPALIVEShort message that proves the peer is alive and confirms an OPEN.
NOTIFICATIONReports an error and closes the session.

The hold time is negotiated in the OPEN messages. If no message arrives within the hold time, the peer is declared down. Keepalives are sent at a fraction of that time so the hold timer never expires on a healthy link.

Session states

A peer goes through Idle, Connect, Active, OpenSent, OpenConfirm and finally Established. Only in Established do UPDATE messages flow.

A session stuck in Active or Connect usually means the TCP connection fails. A session that bounces between states often means a mismatch in the OPEN message, such as the wrong remote-as.

iBGP versus eBGP

A provider router in AS 100 at 203.0.113.1 peers by eBGP with edge router R1 in AS 65001, which passes the route to core router R2 over iBGP with the next hop still 203.0.113.1, so R2 needs a route to that address.

BehavioureBGPiBGP
Peer ASDifferent from localSame as local
AS pathLocal AS is addedNot changed
Next hopNormally set to the sending routerPassed on unchanged
Local preferenceNot sent to the peerCarried between peers
Typical administrative distance20200
Routes learned from this peer typeSent to all peersNot sent to other iBGP peers

The last row is the iBGP split horizon rule. A route learned from one iBGP peer is not passed to another iBGP peer. This prevents loops inside the AS, because the AS path is not changed within it.

The rule means iBGP peers need a full mesh of sessions unless you use route reflectors or confederations. Those are covered on a later page.

The unchanged next hop matters too. An iBGP router may receive a route whose next hop is an address in another AS. If it cannot reach that address, the route is unusable.

ProviderAS 100eBGP next hop 203.0.113.1Edge R1AS 65001iBGP, next hop unchangedCore R2AS 65001

R2 must know how to reach 203.0.113.1, usually through an interior protocol or a static route.

/routing bgp peer add name=isp remote-address=203.0.113.1 remote-as=100
/routing bgp peer add name=r2 remote-address=10.255.255.2 remote-as=65001 nexthop-choice=force-self
/routing bgp peer print status
  • nexthop-choice=force-self makes the router put its own address as the next hop.
  • A peer whose remote-as equals the local AS is treated as iBGP.
Exam tip

When an iBGP router shows a route as inactive, check first whether the next hop is reachable.

What to remember for the exam

Eight facts cover most questions here.

  • BGP uses TCP port 179.
  • The message types are OPEN, UPDATE, KEEPALIVE and NOTIFICATION.
  • The session is fully working only in the Established state.
  • eBGP adds the local AS to the AS path. iBGP does not.
  • eBGP changes the next hop. iBGP leaves it unchanged.
  • A route learned from an iBGP peer is not sent to another iBGP peer.
  • iBGP therefore needs a full mesh, or reflectors, or confederations.
  • Typical administrative distances are 20 for eBGP and 200 for iBGP.
Watch out

Blocking TCP port 179 in a firewall chain is a common reason a peer never reaches Established.

Common mistakes

These four errors appear often.

Expecting iBGP to redistribute between iBGP peers. Routes learned from one iBGP peer stay there, so a partial mesh leaves some routers without routes.

Ignoring the next hop. The route may be present but not active because the next hop is not reachable inside the AS.

Blocking the transport. A firewall rule that drops TCP port 179 keeps the session in Active or Connect.

Confusing UPDATE with KEEPALIVE. Only UPDATE carries prefixes. KEEPALIVE carries no routing data.

Check yourself

Work through these three questions.

  • Which transport protocol and port does BGP use?

    BGP uses TCP port 179.

  • What happens to a route that an iBGP router learned from another iBGP peer?

    It is not advertised to any other iBGP peer. This is why iBGP needs a full mesh, route reflectors or confederations.

  • What does nexthop-choice=force-self do on an iBGP peer?

    It makes the router set its own address as the next hop for the routes it sends. Other routers then do not need a route to the original external next hop.

Topic 2 of 7 in BGP

Test yourself on BGP

The full MikroTik MTCINE question bank has 475 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by MikroTik. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.