Course contents

Module 2: Configuring BGPLesson 2.5 (5 of 6 in this module)8 of 43 in the BGP course

Originating routes: network, redistribute, default-originate

A BGP neighbour only hears about a prefix if some router in your AS puts it into BGP first. You wrote the network command and nothing was advertised. This lesson explains why, and the other ways a route can start.

Advanced · 13 min read

You'll learn to choose between network, redistribution and default-originate, explain the exact-match rule, and read the origin code in show ip bgp.

Where BGP routes come from

BGP has no discovery of its own. It does not look at your interfaces and decide what to tell the world. Every prefix in the BGP table arrived in one of two ways: a neighbour sent it, or something on this router put it there. This lesson is about the second way. The routers that do it are said to originate the route.

Ways a prefix enters BGP on this router
Ways a prefix enters BGP on this routerFour mechanisms and what each one needs.networkExact prefix and mask must alreadybe in the routing tableredistributeCopies routes from another sourceOrigin becomes incompleteaggregate-addressCreates a summary from routesalready in the BGP tabledefault-originateSends 0.0.0.0/0 to one neighbourwithout putting it in the table

On small screens, swipe sideways or focus the diagram and use the arrow keys.

Aggregation and default-originate are covered later in this lesson and in the next one.

What an originated route looks like on the wire

Whichever way a route starts, it leaves in an UPDATE message. The prefix goes in the NLRI field. The attributes go beside it: ORIGIN, an AS_PATH (empty inside the originating AS, your AS number added when it crosses an eBGP session), NEXT_HOP and so on.

Inside an UPDATE message
Inside an UPDATE messageA BGP message starts with a 19 byte header: a 16 byte marker, a 2 byte length and a 1 byte type. The UPDATE body holds the withdrawn routes length, the withdrawn routes, the total path attribute length, the path attributes and the network layer reachability information.Every BGP message: 19 byte headerMarker16 bytes, all onesLength2 bytes, whole messageType1 byte, value 2 = UPDATEUPDATE bodyWithdrawnroutes length2 bytesWithdrawnroutesprefixes removedTotal pathattribute length2 bytesPathattributesORIGIN, AS_PATH ...NLRIprefixesbeing advertisedto removewithdrawhow to get therewhere it leads

On small screens, swipe sideways or focus the diagram and use the arrow keys.

One UPDATE can withdraw prefixes, advertise prefixes, or both. The path attributes apply to every prefix in the NLRI field of that same message, which is why prefixes with different attributes travel in separate UPDATEs.

The network command and the exact-match rule

A network statement needs an exact match in the routing table
A network statement needs an exact match in the routing tableThe router holds three routes in its IP routing table. The statement network 198.51.100.0 mask 255.255.255.0 matches the connected 198.51.100.0/24 exactly, so the prefix enters the BGP table. A /25 or a different mask would not match, and the prefix would not be originated.IP routing table (RIB)198.51.100.0/24connected, Gi0/2198.51.100.0/25static192.0.2.0/30connected, Gi0/0network 198.51.100.0 mask 255.255.255.0the statement under testmatchBGP table198.51.100.0/24, origin IGP, weight 32768Different mask or no routenothing is originated, no error shown

On small screens, swipe sideways or focus the diagram and use the arrow keys.

BGP does not create routes. The network command only says which routes already in the routing table to copy into BGP. If the route is missing or the mask differs, nothing is advertised and no error is shown.

The network command does not turn BGP on for an interface the way it does in OSPF or EIGRP. It says: if this exact prefix is in my routing table, put it in the BGP table. The check is against the RIB, so a connected, static or IGP route all qualify. If the prefix is missing, or the mask differs by even one bit, the statement does nothing and the router gives no warning.

How the router evaluates a network statement
How the router evaluates a network statementThe statement is checked against the routing table.network198.51.100.0 mask255.255.252.0Look in RIBIs 198.51.100.0/22there exactly?BGP tableYes: origin iNo: nothing

On small screens, swipe sideways or focus the diagram and use the arrow keys.

If the check fails, the route is not in BGP, and so it is not advertised. It is not an error.
ip route 198.51.100.0 255.255.252.0 Null0 ! router bgp 64500 address-family ipv4 unicast network 198.51.100.0 mask 255.255.252.0

R1. The static route to Null0 is the usual way to make the exact aggregate prefix exist when the address space is spread across several smaller subnets. More specific routes still carry the real traffic.

Illustrative Cisco IOS XE output written for this lesson, not a router capture
R1#show ip bgp 198.51.100.0/22
BGP routing table entry for 198.51.100.0/22, version 2
Paths: (1 available, best #1, table default)
  Advertised to update-groups:
     1
  Local
    0.0.0.0 from 0.0.0.0 (192.0.2.254)
      Origin IGP, metric 0, localpref 100, weight 32768, valid, sourced, local, best
Local with a next hop of 0.0.0.0 means this router originated the route. Weight 32768 is what IOS gives locally sourced routes. Origin IGP is the i you see in the table.

Classful networks and auto-summary

If you type network 1.0.0.0 with no mask, IOS assumes the classful mask for that address (here /8) and still needs exactly 1.0.0.0/8 in the routing table. Nothing is advertised if the router only has 1.1.1.1/32. The auto-summary command changes that: with it, the router originates the classful network as soon as any subnet of it is in the routing table. Auto-summary is off by default in current IOS XE, which is what you want, because a summary the router does not really have can attract traffic it cannot deliver.

The same network statement, two behaviours
The same network statement, two behavioursWith and without auto-summary.auto-summary offnetwork 1.0.0.0Needs 1.0.0.0/8in the routing tableauto-summary onnetwork 1.0.0.0Any 1.x.x.x subnetis enoughvs

On small screens, swipe sideways or focus the diagram and use the arrow keys.

Auto-summary originates a classful route from any matching subnet. Leave it off and write the exact prefix instead.

Redistribution and the incomplete origin

The redistribute command copies routes from another source into BGP. It saves typing, but it takes everything: every connected subnet, every OSPF route, whatever happens to be there. The ORIGIN attribute records how a route entered BGP, and redistributed routes get incomplete (?), because BGP does not know where they came from.

network or redistribute
network or redistributeTwo ways to originate, with different control.networkOrigin: IGP (i)You list each prefixPredictableredistributeOrigin: incomplete (?)Brings in a whole tableNeeds a route mapvs

On small screens, swipe sideways or focus the diagram and use the arrow keys.

Both put routes in BGP. network is explicit and redistribute is bulk.

ORIGIN is the third tie-breaker in the best-path order after weight, local preference and locally originated: IGP is preferred to EGP, which is preferred to incomplete. For one prefix reachable by two methods, this decides the winner.

route-map CONNECTED-TO-BGP permit 10 match ip address prefix-list OWN-PREFIXES ! router bgp 64500 address-family ipv4 unicast redistribute connected route-map CONNECTED-TO-BGP

R1. If you must redistribute, always pass the routes through a route map so only the prefixes you own can enter. An unfiltered redistribute connected can advertise your link subnets to the internet.

Sending a default route with default-originate

default-originate sends a default to one neighbour
default-originate sends a default to one neighbourThe provider edge router PE sends a default route 0.0.0.0/0 to its customer CE with default-originate. The router does not need a default route of its own. The default goes only to the neighbour that carries the command, and the other neighbours receive the normal table.Customer CEAS 64510PEAS 64500Other peerAS 645020.0.0.0/0normal tableneighbor 192.0.2.10 default-originateapplies to this neighbour onlyOptional route-mapsend the default only when a condition holds

On small screens, swipe sideways or focus the diagram and use the arrow keys.

Use it to give a customer or branch a default without exporting the full table. It is a per-neighbour setting, so check which session carries it before expecting the default elsewhere.

An ISP often sends a customer nothing but a default route. Rather than put 0.0.0.0/0 in its own table, it can tell BGP to give the default to one neighbour directly.

router bgp 64501 address-family ipv4 unicast neighbor 192.0.2.2 default-originate

ISP A. Sends 0.0.0.0/0 to the neighbour whether or not the ISP itself has a default route. The route is not added to the ISP's own BGP table.

Add a route map and the default is sent only while the route map matches something. That makes it conditional: advertise a default only while a route that proves the upstream is healthy is present.

ip prefix-list UPSTREAM-OK seq 5 permit 203.0.113.0/24 ! route-map DEFAULT-IF-UP permit 10 match ip address prefix-list UPSTREAM-OK ! router bgp 64501 address-family ipv4 unicast neighbor 192.0.2.2 default-originate route-map DEFAULT-IF-UP

ISP A. With the route map, the default is advertised only while 203.0.113.0/24 is in the routing table.

Illustrative Cisco IOS XE output written for this lesson, not a router capture
R1#show ip bgp neighbors 192.0.2.1 received-routes
     Network          Next Hop            Metric LocPrf Weight Path
 *>  0.0.0.0          192.0.2.1                              0 64501 i

Total number of prefixes 1
The company router sees the default arrive from ISP A with ISP A in the AS path. It treats it like any other BGP route, so the same local preference and filter rules apply.

Verifying that a route was originated and advertised

Check in this order
Check in this orderThree show commands, from the table to the neighbour.RIBshow ip routeexact prefix?BGP tableshow ip bgpLocal, weight 32768Neighbouradvertised-routesis it sent?

On small screens, swipe sideways or focus the diagram and use the arrow keys.

Stop at the first one that fails: that is where the route is lost.
show ip route 198.51.100.0 255.255.252.0 show ip bgp 198.51.100.0/22 show ip bgp neighbors 192.0.2.1 advertised-routes

Privileged EXEC mode. The first confirms the network statement can match, the second that BGP originated it, the third that your outbound policy let it through.

Technical reference: RFC 4271, A Border Gateway Protocol 4 (BGP-4), sections 4.3 and 5.1.1. Output above is illustrative.

Check your understanding

Predict · scenario 1

You configure network 198.51.100.0 mask 255.255.255.0, but the RIB holds only 198.51.100.0/23 from OSPF. What does BGP advertise?

Predict · scenario 2

A prefix enters BGP by redistribute connected. What does show ip bgp show as the origin code?

Predict · scenario 3

neighbor 192.0.2.2 default-originate route-map DEFAULT-IF-UP is configured. When is the default sent?

FAQ

Why does my network statement advertise nothing?
BGP checks the routing table, not the interface. The same prefix and mask must be present in the RIB from any source. If a /24 is configured but only a /23 is in the RIB, nothing is originated.
Why do I need a static route to Null0 for a network statement?
Your aggregate address space is often not on any single interface. A static route to Null0 puts the exact prefix in the RIB so network can originate it. More specific routes still win for real traffic.
Which is better, network or redistribute?
network, for almost every enterprise edge. It names exactly what you advertise. Redistribution brings in whatever the other protocol holds, which is a common source of accidental leaks.