Redistribute BGP Route into OSPF in Cisco IOS Router

Spread the love

When we run BGP together with any IGP routing, sometimes it is required to redistribute BGP routes into that IGP. This usually required where BGP peers are separated by certain number of hops that aren’t participating in BGP — so they don’t know the route to the destination network that is advertised by BGP. In Cisco IOS router, we can redistribute either one or both external and internal BGP into any IGP, such as OSPF. This article will show an example that demonstrates the steps to Redistribute BGP Route into OSPF in Cisco IOS Router.

The following scenario will be used throughout the article to show the way to redistribute BGP route into OSPF in Cisco IOS router:

Redistribute BGP Route into OSPF in Cisco IOS Router

There are four routers in AS65535 and they are running OSPF for their internal routing. R1 is the ASBR and eBGP configuration has been added for peering with R5 in AS65531. Also, iBGP configuration has been added on R1 for internal peering with R3 in AS65535. R2 and R4 are not BGP speakers.

R3 has advertised Lo1 and Lo2 interfaces in its BGP configuration and all the advertised networks are visible in routing table of both R1 and R5. R5 has advertise its loopback interface as well and it’s visible in both R1 and R3. But, ping from Lo0 in R5 to Lo1/Lo2 in R3 is failing.

R5#ping 172.30.30.1 sour lo0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.30.30.1, timeout is 2 seconds:
Packet sent with a source address of 5.5.5.5
.....
Success rate is 0 percent (0/5)
R5#ping 172.30.31.1 sour lo0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.30.31.1, timeout is 2 seconds:
Packet sent with a source address of 5.5.5.5
.....
Success rate is 0 percent (0/5)

Now we will solve this issue without touching the configuration in R2 and R4.

BGP Configuration and Routing Table Verification

Below are configurations from all the BGP routers before we do the changes:

R1#sh run  | s router
router ospf 1
network 1.1.1.1 0.0.0.0 area 0
network 10.12.12.1 0.0.0.0 area 0
network 10.14.14.1 0.0.0.0 area 0
router bgp 65535
bgp log-neighbor-changes
neighbor 3.3.3.3 remote-as 65535
neighbor 3.3.3.3 update-source Loopback0
neighbor 3.3.3.3 next-hop-self
neighbor 192.168.15.5 remote-as 65531
R3#sh run | s router
router ospf 1
network 3.3.3.3 0.0.0.0 area 0
network 10.23.23.3 0.0.0.0 area 0
network 10.34.34.3 0.0.0.0 area 0
router bgp 65535
bgp log-neighbor-changes
network 172.30.30.0 mask 255.255.255.0
network 172.30.31.0 mask 255.255.255.0
aggregate-address 172.30.30.0 255.255.254.0 summary-only
neighbor 1.1.1.1 remote-as 65535
neighbor 1.1.1.1 update-source Loopback0
R5#sh run | s router
router bgp 65531
bgp log-neighbor-changes
network 5.5.5.5 mask 255.255.255.255
neighbor 192.168.15.1 remote-as 65535

Below is BGP routing table in R5. Route 172.30.30.0/23 has been visible but as shown above, ping to these networks are not working at the moment.

R5#sh ip route 172.30.30.0
Routing entry for 172.30.30.0/23
Known via "bgp 65531", distance 20, metric 0
Tag 65535, type external
Last update from 192.168.15.1 00:34:01 ago
Routing Descriptor Blocks:
* 192.168.15.1, from 192.168.15.1, 00:34:01 ago
Route metric is 0, traffic share count is 1
AS Hops 1
Route tag 65535
MPLS label: none

On R3, the route 5.5.5.5/32 has been visible as well. So there should be no issue here.

R3#sh ip route 5.5.5.5
Routing entry for 5.5.5.5/32
Known via "bgp 65535", distance 200, metric 0
Tag 65531, type internal
Last update from 1.1.1.1 00:13:47 ago
Routing Descriptor Blocks:
* 1.1.1.1, from 1.1.1.1, 00:13:47 ago
Route metric is 0, traffic share count is 1
AS Hops 1
Route tag 65531
MPLS label: none

On R1, route to R3 and R5 advertised networks are visible as well.

R1#sh ip route bgp | b Gate
Gateway of last resort is not set

5.0.0.0/32 is subnetted, 1 subnets
B 5.5.5.5 [20/0] via 192.168.15.5, 00:30:57
172.30.0.0/23 is subnetted, 1 subnets
B 172.30.30.0 [200/0] via 3.3.3.3, 00:30:07

So if routes in all BGP routers looks good, then it means the problem is on the non-BGP routers, or in this case are R2 and R4. If we check the routing table on R2 and R4, none of them will know the routes to 5.5.5.5/32 and 172.30.30.0/23.

R2#sh ip route 5.5.5.5
% Network not in table
R2#sh ip route 172.30.30.0
% Network not in table
R4#sh ip route 5.5.5.5
% Network not in table
R4#sh ip route 172.30.30.0
% Network not in table

So even if these routers are not BGP speakers, but they still need to know where to forward the packet. To do this, we can redistribute the route information from R1 to R2 and R4.

How to Redistribute BGP Route into OSPF in Cisco IOS Router

To redistribute BGP route into OSPF in Cisco IOS router, use this command under OSPF configuration: “redistribute bgp [AS_Number] subnets

Firstly, we do the redistribution on R1:

R1(config)#router ospf 1
R1(config-router)#redistribute bgp 65535 subnets

Now look at R2 or R4 routing table after configuring as above:

R2#sh ip route 5.5.5.5
Routing entry for 5.5.5.5/32
Known via "ospf 1", distance 110, metric 1
Tag 65531, type extern 2, forward metric 1
Last update from 10.12.12.1 on FastEthernet0/0, 00:00:01 ago
Routing Descriptor Blocks:
* 10.12.12.1, from 1.1.1.1, 00:00:01 ago, via FastEthernet0/0
Route metric is 1, traffic share count is 1
Route tag 65531
R2#sh ip route 172.30.30.0
% Network not in table

Route to 5.5.5.5/32 exists, but route to 172.30.30.0/23 still not exist. This is because by default when we redistribute BGP into any IGP, it will not redistribute routes learned from iBGP.

If we look at BGP information in R1 using command “show ip bgp”, we can see below that route to 172.30.30.0/23 is indeed learned from iBGP (see the “*>i” remarks in the entry, indicating that it is an internal route) and this is why R1 is not redistributing it to R2/R4.

R1#show ip bgp
BGP table version is 4, local router ID is 1.1.1.1
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,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

Network Next Hop Metric LocPrf Weight Path
*> 5.5.5.5/32 192.168.15.5 0 0 65531 i
*>i 172.30.30.0/23 3.3.3.3 0 100 0 i

This is an expected result in our case because we don’t want R1 to advertise the route to 172.30.30.0/23 to R2 and R4. This network belongs to R3 and therefore R3 must be the one to redistribute it. Now we can configure redistribution on R3 the same way we did on R1:

R3(config)#router ospf 1
R3(config-router)#redistribute bgp 65535 subnets

Then we can look at the result on R2/R4:

R2#sh ip route 172.30.30.0
Routing entry for 172.30.30.0/24
Known via "ospf 1", distance 110, metric 1, type extern 2, forward metric 1
Last update from 10.23.23.3 on FastEthernet0/1, 00:00:29 ago
Routing Descriptor Blocks:
* 10.23.23.3, from 172.30.31.1, 00:00:29 ago, via FastEthernet0/1
Route metric is 1, traffic share count is 1

Now R2 and R4 has already obtained the information for route to both R3 and R5 advertised networks. Also, ping between R3 and R5 can now be performed successfully.

R5#ping 172.30.30.1 sour lo0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.30.30.1, timeout is 2 seconds:
Packet sent with a source address of 5.5.5.5
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 44/55/60 ms
R5#ping 172.30.31.1 sour lo0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.30.31.1, timeout is 2 seconds:
Packet sent with a source address of 5.5.5.5
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 40/56/64 ms

And that’s how you redistribute BGP routes into OSPF in Cisco IOS Router.

The following two tabs change content below.

Arranda Saputra

ITIL Certified, CCNA, CCDA, VCP6-DCV, MCSA Administering Windows Server 2012
I am IT practitioner in real life with specialization in network and server infrastructure. I have years of experience in design, analysis, operation, and optimization of infrastructure solutions for enterprise-scaled network. You can send me a message on LinkedIn or email to arranda.saputra@outlook.com for further inquiry regarding stuffs that I wrote or opportunity to collaborate in a project.

Latest posts by Arranda Saputra (see all)

scroll to top