cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
13648
Views
0
Helpful
5
Replies

redistributing BGP int OSPF usibg route-maps

smith606306
Level 1
Level 1

Hi,

I am trying to redistribute BGP networks into ospf using route-maps.

Every network redistributes and i want to filter it for certain networks.

Below is the config I have been trying

TEST-A#sh run | begin router ospf
router ospf 100
log-adjacency-changes
redistribute static subnets
redistribute bgp 65169 subnets route-map BGP_OSPF
network 10.1.1.0 0.0.0.255 area 0
network 10.20.191.0 0.0.0.255 area 0
network 10.80.24.0 0.0.0.255 area 0
network 130.0.0.0 0.255.255.255 area 0
network 172.16.1.0 0.0.0.255 area 0
network 172.29.94.160 0.0.0.31 area 0
network 172.29.94.192 0.0.0.31 area 0
network 172.29.94.224 0.0.0.31 area 0
network 192.168.40.0 0.0.0.15 area 0
default-information originate
!
router bgp 65169
bgp log-neighbor-changes
neighbor 172.18.1.32 remote-as 65000
neighbor 172.18.1.32 update-source Loopback0
neighbor 192.168.1.10 remote-as 65000
neighbor 192.168.1.10 update-source GigabitEthernet5/48
!
ip classless
no ip forward-protocol udp netbios-ns
no ip forward-protocol udp netbios-dgm
no ip http server
!
!
access-list 99 permit 10.18.196.0 0.0.0.255 log
access-list 99 permit 10.20.196.0 0.0.0.255 log
route-map BGP_OSPF permit 10
match ip address 99
!
route-map BGP_OSPF deny 50

any help would be appreciated

2 Accepted Solutions

Accepted Solutions

Peter Paluch
Cisco Employee
Cisco Employee

Andrew,

A few questions to clarify your issue:

  1. You are complaining that all BGP-learned routes are being redistributed into OSPF, right?
  2. What routes exactly are redistributed? Please include a simple example - a couple of networks which you do not want to have redistributed but which still are; please indicate their complete IP address and mask.
  3. Using prefix lists is better to control the redistribution, as the prefix lists allow you to check both the network address and mask. The corresponding configuration would be:

ip prefix-list PL-BGP-to-OSPF permit 10.18.196.0/24

ip prefix-list PL-BGP-to-OSPF permit 10.20.196.0/24

route-map BGP_OSPF permit 10

match ip address prefix PL-BGP-to-OSPF

route-map BGP_OSPF deny 50

Best regards,

Peter

View solution in original post

Andrew,

Let me assure one thing: you are complaining about extra networks being redistributed from BGP to OSPF but you have shown me the BGP-learned routes in the routing table and in the BGP database. Even with filtered redistribution, these networks from BGP will still be present in the routing table and in the BGP database. What shall change is the routing table on your OSPF neighbors. Have you made sure that their routing table still contains the unwelcome BGP routes even after configuring the prefix list?

If the issue still persists please enclose the output of the show ip ospf database external command - it will be probably longer but it is required.

Best regards,

Peter

View solution in original post

5 Replies 5

Peter Paluch
Cisco Employee
Cisco Employee

Andrew,

A few questions to clarify your issue:

  1. You are complaining that all BGP-learned routes are being redistributed into OSPF, right?
  2. What routes exactly are redistributed? Please include a simple example - a couple of networks which you do not want to have redistributed but which still are; please indicate their complete IP address and mask.
  3. Using prefix lists is better to control the redistribution, as the prefix lists allow you to check both the network address and mask. The corresponding configuration would be:

ip prefix-list PL-BGP-to-OSPF permit 10.18.196.0/24

ip prefix-list PL-BGP-to-OSPF permit 10.20.196.0/24

route-map BGP_OSPF permit 10

match ip address prefix PL-BGP-to-OSPF

route-map BGP_OSPF deny 50

Best regards,

Peter

cadet alain
VIP Alumni
VIP Alumni

Hi,

syntax of route map and ACl as well as redistribution looks good.

Can you do a show route-map and show acl.

Regards. 

Don't forget to rate helpful posts.

1. Yes I am complaining all BGP learned routes are being redistributed.

2. Routes redistributed (this is a test network)

C4506-TEST-A#sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route

Gateway of last resort is not set

     172.16.0.0/24 is subnetted, 1 subnets
C       172.16.1.0 is directly connected, Loopback0
     172.18.0.0/24 is subnetted, 1 subnets
B       172.18.1.0 [20/0] via 192.168.1.10, 00:08:16
     10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
B       10.18.123.0/24 [20/0] via 192.168.1.10, 00:08:16
B       10.20.123.0/27 [20/0] via 192.168.1.10, 00:08:16
B       10.20.196.0/27 [20/0] via 192.168.1.10, 00:08:16
B       10.18.196.0/24 [20/0] via 192.168.1.10, 00:08:16
B    130.196.0.0/16 [20/0] via 192.168.1.10, 00:08:16
B    130.193.0.0/16 [20/0] via 192.168.1.10, 00:08:16
     192.168.1.0/30 is subnetted, 3 subnets
C       192.168.1.8 is directly connected, GigabitEthernet5/48
B       192.168.1.12 [20/0] via 192.168.1.10, 00:08:19
B       192.168.1.4 [20/0] via 192.168.1.10, 00:08:19

I dont want the BGP networks apart from 10.18.196.0 255.255.255.0 and 10.20.196.0 255.255.255.224

C4506-TEST-A#sh run | begin router ospf
router ospf 100
log-adjacency-changes
redistribute static subnets
redistribute bgp 65169 subnets route-map BGP_OSPF
network 10.1.1.0 0.0.0.255 area 0
network 10.20.191.0 0.0.0.255 area 0
network 10.80.24.0 0.0.0.255 area 0
network 172.16.1.0 0.0.0.255 area 0
network 172.29.94.160 0.0.0.31 area 0
network 172.29.94.192 0.0.0.31 area 0
network 172.29.94.224 0.0.0.31 area 0
network 192.168.40.0 0.0.0.15 area 0
default-information originate
!
router bgp 65169
bgp log-neighbor-changes
network 192.168.1.2 mask 255.255.255.252
neighbor 172.18.1.32 remote-as 65000
neighbor 172.18.1.32 update-source Loopback0
neighbor 192.168.1.2 remote-as 65000
neighbor 192.168.1.2 ebgp-multihop 10
neighbor 192.168.1.2 update-source GigabitEthernet5/48
neighbor 192.168.1.10 remote-as 65000
neighbor 192.168.1.10 update-source GigabitEthernet5/48
!
ip classless
no ip forward-protocol udp netbios-ns
no ip forward-protocol udp netbios-dgm
no ip http server
!
!
ip prefix-list BGP_OSPF seq 5 permit 10.18.196.0/24
ip prefix-list BGP_OSPF seq 10 permit 10.20.196.0/27
!
route-map BGP_OSPF permit 10
match ip address prefix-list BGP_OSPF
!
route-map BGP_OSPF deny 50
!
!
!
line con 0
stopbits 1

C4506-TEST-A#sh ip bgp
BGP table version is 11, local router ID is 172.16.1.24
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 10.18.123.0/24   192.168.1.10                           0 65000 i
*> 10.18.196.0/24   192.168.1.10             0             0 65000 i
*> 10.20.123.0/27   192.168.1.10                           0 65000 i
*> 10.20.196.0/27   192.168.1.10             0             0 65000 i
*> 130.193.0.0      192.168.1.10             0             0 65000 i
*> 130.196.0.0      192.168.1.10             0             0 65000 i
*> 172.18.1.0/24    192.168.1.10             0             0 65000 i
*> 192.168.1.4/30   192.168.1.10                           0 65000 i
*> 192.168.1.8/30   192.168.1.10             0             0 65000 i
*> 192.168.1.12/30  192.168.1.10             0             0 65000 i

C4506-TEST-A#sh ip prefix-list
ip prefix-list BGP_OSPF: 2 entries
   seq 5 permit 10.18.196.0/24
   seq 10 permit 10.20.196.0/27

C4506-TEST-A#sh route-map
route-map BGP_OSPF, permit, sequence 10
  Match clauses:
    ip address prefix-lists: BGP_OSPF
  Set clauses:
  Policy routing matches: 0 packets, 0 bytes
route-map BGP_OSPF, deny, sequence 50
  Match clauses:
  Set clauses:
  Policy routing matches: 0 packets, 0 bytes

As you can see I tried using prefix-lists but still did not work.

Andrew,

Let me assure one thing: you are complaining about extra networks being redistributed from BGP to OSPF but you have shown me the BGP-learned routes in the routing table and in the BGP database. Even with filtered redistribution, these networks from BGP will still be present in the routing table and in the BGP database. What shall change is the routing table on your OSPF neighbors. Have you made sure that their routing table still contains the unwelcome BGP routes even after configuring the prefix list?

If the issue still persists please enclose the output of the show ip ospf database external command - it will be probably longer but it is required.

Best regards,

Peter

You're right it was working all the time. For some reason I was expecting the routes not to appear in the routing table.

s

Review Cisco Networking products for a $25 gift card