Certopolis

CompTIA Network+ (V9)

OSPF vs BGP explained for Network+

OSPF is a link-state protocol run inside one autonomous system: every router in an area holds the same topology database and computes its own shortest-path tree. BGP runs between autonomous systems over TCP port 179 and carries the list of ASes each route has crossed. Inside an AS, BGP speakers share the external routes over IBGP, and LOCAL_PREF tells them all which exit to prefer.

OSPF: link state inside one AS

RFC 2328 says each OSPF router maintains an identical database describing the topology. Each router floods its local state, and from the database each one builds a tree of shortest paths with itself as root.

OSPF splits a network into areas. The backbone is Area 0 (written 0.0.0.0). It always contains all area border routers and carries routing information between non-backbone areas. It must be contiguous, though virtual links can keep it connected.

On broadcast networks such as Ethernet a Designated Router is elected by the Hello protocol to reduce the number of adjacencies. Each interface has a configurable cost, and OSPF prefers the lowest total cost. OSPF runs directly over IP as protocol number 89.

BGP: path vector between ASes

RFC 4271 says BGP uses TCP as its transport and listens on port 179. A BGP speaker exchanges reachability information that includes the list of ASes the route has crossed, enough to build a graph of AS connectivity and prune routing loops.

A peer in a different AS is an external peer (EBGP). A peer in the same AS is an internal peer (IBGP). The interior protocol, such as OSPF, gives a consistent view of interior routes. A consistent view of exterior routes comes from all BGP speakers in the AS keeping IBGP sessions with each other. Two edge routers that each learn routes from a different provider share them over IBGP.

If a route's AS_PATH contains the local AS number, the route has looped and is excluded.

Steering traffic with BGP attributes

LOCAL_PREF is sent only to internal peers. A speaker sets a degree of preference for each external route from local policy, and the higher value must be preferred. To make every router in your AS leave through one link, give routes learned over that link a higher LOCAL_PREF.

LOCAL_PREF steers traffic leaving your AS. RFC 4271 says MULTI_EXIT_DISC is used on links between ASes to discriminate among multiple exit or entry points to the same neighbouring AS. You set it on routes you advertise to a provider to suggest which of your links it should use to send traffic in.

Where the exam catches people

  • Believing two routers in the same AS exchange provider routes over EBGP: peers in the same AS are internal peers, so the session is IBGP.
  • Believing MED makes your own routers prefer an exit: LOCAL_PREF does that. MED is a hint to the neighbouring AS.
  • Believing OSPF runs over TCP or UDP: it is IP protocol 89. BGP is the one on TCP 179.
  • Believing a distance-vector protocol holds a full topology map: in a link-state protocol like OSPF every router in the area holds the identical database.

Written from CompTIA's documentation

Try 3 questions on this

Pick an answer to see why each option is right or wrong.

  1. A routing protocol has every router hold an identical database of the whole area's topology and compute its own tree of best paths from it. Which of the following protocols works this way?

    Right. In the game that’s Renown for your Network Implementation building.

    Not that one: D is right. In the game your Network Implementation building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    Each participating router has an identical database', and 'From the link-state database, each router constructs a tree of shortest paths with itself as root.' Distance-vector and path-vector protocols hold no such map.

    Written from www.rfc-editor.org/rfc/rfc2328.html

  2. Two edge routers in one autonomous system each learn routes from a different upstream provider and must exchange those exterior routes with each other. Which of the following sessions carries them?

    Right. In the game that’s Renown for your Network Implementation building.

    Not that one: C is right. In the game your Network Implementation building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    The interior gateway protocol provides a consistent view of the interior routes only, so the exterior routes learned from each provider travel between the two edge routers over an IBGP session.

    Written from www.rfc-editor.org/rfc/rfc4271.html

  3. An organization with two Internet links wants every router inside its autonomous system to prefer the exit through one link for all external destinations. Which of the following BGP attributes should be set?

    Right. In the game that’s Renown for your Network Implementation building.

    Not that one: A is right. In the game your Network Implementation building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    Setting a higher LOCAL_PREF on routes learned over the favored link makes every internal peer choose that exit.

    Written from www.rfc-editor.org/rfc/rfc4271.html