In this quick blog post, we're going to talk about BGP origin codes. Ever seen an 'i' or a '?' next to your routes and wondered what they mean? We'll go through an example to help you understand what this means.
If you are looking for a short answer
- If you use a
network x.x.x.xcommand under the BGP process, the routes would show up as Origin IGP (i)
- If you redistribute the routes directly from an IGP (static, connected, OSPF, EIGRP) into BGP, the routes would show up as Origin incomplete (?)
- e (EGP) is very rare nowadays but if you see it then the routes come from EGP
BGP Origin Codes
Origin is a well-known mandatory BGP Path attribute that defines the Origin of routing information, aka, how a route became a BGP route. Well-known mandatory attributes must be recognized by all BGP implementations and included with every prefix advertisement. So, you will see them in each and every BGP prefixes.
There are three types of Origin Codes:
i(IGP) - Has the highest priority and routes are added to the BGP routing table using the
e(EGP) - This is pretty rare, but it means the route came from EGP. You won't see this often.
?(incomplete) - The routes that are redistributed from other routing protocols to BGP.
When I say IGP Origin code has the highest priority what I meant was that let’s say a router learns about the same route from two different places, and everything else about (Weight, Local Preference, AS_Path) these routes are the same. What happens next? Your router will take a look at the origin code to break the tie. If one of the routes has an origin code of 'i', that route is the winner.
Here is a simple example with four routers. router-01 and router-02 has formed an eBGP neighbourship. router-01 also has an OSPF neighbourship with router-03.
The below shows the routing table of router-01 where router-03's loopback (192.168.30.1/32) is learnt via OSPF and router-04's loopback (192.168.40.1/32) is learnt via static route.
router-01# Gateway of last resort is not set ! Abbriviated! 192.168.30.0/32 is subnetted, 1 subnets O 192.168.30.1 [110/11] via 192.168.13.3, 22:42:29, Ethernet0/1 192.168.40.0/32 is subnetted, 1 subnets S 192.168.40.1 [1/0] via 192.168.14.4
router-01 in turn advertises these routes to BGP using the
network statement as you can see below.
router-01# router bgp 64512 bgp router-id 22.214.171.124 bgp log-neighbor-changes network 192.168.30.1 mask 255.255.255.255 network 192.168.40.1 mask 255.255.255.255 neighbor 192.168.12.2 remote-as 64513
Now if you look at router-02's BGP summary, you will see
i next to those two loopbacks which indicates the routes was initially learnt using the
router-02#show bgp ipv4 unicast BGP table version is 6, local router ID is 126.96.36.199 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, x best-external, a additional-path, c RIB-compressed, t secondary path, Origin codes: i - IGP, e - EGP, ? - incomplete RPKI validation codes: V valid, I invalid, N Not found Network Next Hop Metric LocPrf Weight Path *> 192.168.30.1/32 192.168.12.1 11 0 64512 i <<< *> 192.168.40.1/32 192.168.12.1 0 0 64512 i <<<
Now, let's go to router-01, remove the network statement for 192.168.40.1/32 and redistribute the static routes into BGP and see what happens to router-02's point of view.
router-01# router bgp 64512 bgp router-id 188.8.131.52 bgp log-neighbor-changes network 192.168.30.1 mask 255.255.255.255 redistribute static <<< neighbor 192.168.12.2 remote-as 64513
router-02#show bgp ipv4 unicast BGP table version is 13, local router ID is 184.108.40.206 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, x best-external, a additional-path, c RIB-compressed, t secondary path, Origin codes: i - IGP, e - EGP, ? - incomplete RPKI validation codes: V valid, I invalid, N Not found Network Next Hop Metric LocPrf Weight Path *> 192.168.30.1/32 192.168.12.1 11 0 64512 i *> 192.168.40.1/32 192.168.12.1 0 0 64512 ? <<<
ahh, as you can see above, now the origin has changed to
? which indicates the route was learnt via redistribution.