Monday, December 2, 2013

BGP redistribute-internal




Elements

In this example we will examine a hidden command: bgp redistribute-internal
R1 is running OSPF with R2, iBGP with R3 (EIGRP is for loopbacks connectivity) and eBGP with R4
As known, when we redistribute BGP into a routing protocol, only eBGP routes are redistributed, let us find and see


Configuration

R1
interface Loopback0
 ip address 1.1.1.1 255.255.255.255

interface FastEthernet0/0
 ip address 192.168.12.1 255.255.255.0
 speed 100
 full-duplex

interface FastEthernet0/1
 ip address 192.168.13.1 255.255.255.0
 speed 100
 full-duplex

interface Serial0/0
 ip address 192.168.14.1 255.255.255.0
 encapsulation ppp

router ospf 1
 router-id 1.1.1.1
 log-adjacency-changes
 redistribute bgp 1 subnets
 network 192.168.12.1 0.0.0.0 area 0

router eigrp 1
 network 1.1.1.1 0.0.0.0
 network 192.168.13.1 0.0.0.0
 no auto-summary

router bgp 1
 neighbor 3.3.3.3 remote-as 1
 neighbor 3.3.3.3 update-source Loopback0
 neighbor 192.168.14.4 remote-as 4
 no auto-summary

R2

interface Loopback0
 ip address 2.2.2.2 255.255.255.255

interface FastEthernet0/0
 ip address 192.168.12.2 255.255.255.0
 speed 100
 full-duplex
router ospf 1
 router-id 2.2.2.2
 log-adjacency-changes
 network 2.2.2.2 0.0.0.0 area 0
 network 192.168.12.2 0.0.0.0 area 0

R3

interface Loopback0
 ip address 3.3.3.3 255.255.255.255

interface Loopback1
 ip address 13.13.13.13 255.255.255.255

interface FastEthernet0/0
 ip address 192.168.13.3 255.255.255.0
 speed 100
 full-duplex

R3#sh run | sec router eigrp
router eigrp 1
 network 3.3.3.3 0.0.0.0
 network 192.168.13.3 0.0.0.0
 no auto-summary

router bgp 1
network 3.3.3.3 mask 255.255.255.255
 network 13.13.13.13 mask 255.255.255.255
 neighbor 1.1.1.1 remote-as 1
 neighbor 1.1.1.1 update-source Loopback0
 no auto-summary

R4
interface Loopback0
 ip address 4.4.4.4 255.255.255.255

interface Serial0/0
 ip address 192.168.14.4 255.255.255.0
 encapsulation ppp
 clock rate 2000000

router bgp 4
network 4.4.4.4 mask 255.255.255.255
 neighbor 192.168.14.1 remote-as 1
 no auto-summary
Verification

Now let us check basic relations and route advertisements before we do the redistribution
 
R1#sh ip ospf neighbor 
 
Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           1   FULL/DR         00:00:36    192.168.12.2    FastEthernet0/0
 
R1#sh ip route ospf 
     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/2] via 192.168.12.2, 00:38:13, FastEthernet0/0
 
R1#sh ip bgp summary 
BGP router identifier 1.1.1.1, local AS number 1
BGP table version is 5, main routing table version 5
3 network entries using 360 bytes of memory
3 path entries using 156 bytes of memory
3/2 BGP path/bestpath attribute entries using 372 bytes of memory
1 BGP AS-PATH entries using 24 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
Bitfield cache entries: current 2 (at peak 2) using 64 bytes of memory
BGP using 976 total bytes of memory
BGP activity 3/0 prefixes, 3/0 paths, scan interval 60 secs
 
Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
3.3.3.3         4     1      42      41        5    0    0 00:36:19        2
192.168.14.4    4     4      41      42        5    0    0 00:37:13        1
 
R1#sh ip bgp 
BGP table version is 5, 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
Origin codes: i - IGP, e - EGP, ? - incomplete
 
   Network          Next Hop            Metric LocPrf Weight Path
r>i3.3.3.3/32       3.3.3.3                  0    100      0 i
*> 4.4.4.4/32       192.168.14.4             0             0 4 i
*>i13.13.13.13/32   3.3.3.3                  0    100      0 i
 
R2#sh ip ospf neighbor 
 
Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1           1   FULL/BDR        00:00:39    192.168.12.1    FastEthernet0/0
R2#sh ip route ospf 
 
R2#
 
R3#sh ip bgp summary 
BGP router identifier 3.3.3.3, local AS number 1
BGP table version is 3, main routing table version 3
3 network entries using 360 bytes of memory
3 path entries using 156 bytes of memory
3/1 BGP path/bestpath attribute entries using 372 bytes of memory
1 BGP AS-PATH entries using 24 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
Bitfield cache entries: current 1 (at peak 1) using 32 bytes of memory
BGP using 944 total bytes of memory
BGP activity 3/0 prefixes, 3/0 paths, scan interval 60 secs
 
Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
1.1.1.1         4     1      41      42        3    0    0 00:36:40        1
 
R3#sh ip bgp 
BGP table version is 3, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
 
   Network          Next Hop            Metric LocPrf Weight Path
*> 3.3.3.3/32       0.0.0.0                  0         32768 i
* i4.4.4.4/32       192.168.14.4             0    100      0 4 i
*> 13.13.13.13/32   0.0.0.0                  0         32768 i
 
R4#sh ip bgp summary 
BGP router identifier 4.4.4.4, local AS number 4
BGP table version is 4, main routing table version 4
3 network entries using 360 bytes of memory
3 path entries using 156 bytes of memory
3/2 BGP path/bestpath attribute entries using 372 bytes of memory
1 BGP AS-PATH entries using 24 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
Bitfield cache entries: current 1 (at peak 1) using 32 bytes of memory
BGP using 944 total bytes of memory
BGP activity 3/0 prefixes, 3/0 paths, scan interval 60 secs
 
Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
192.168.14.1    4     1      42      41        4    0    0 00:37:42        2
 
R4#sh ip bgp         
BGP table version is 4, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
 
   Network          Next Hop            Metric LocPrf Weight Path
*> 3.3.3.3/32       192.168.14.1                           0 1 i
*> 4.4.4.4/32       0.0.0.0                  0         32768 i
*> 13.13.13.13/32   192.168.14.1                           0 1 i
 
So , all is functioning normal , now let us do one way redistribution from BGP into OSPF on R1 , R2 should according to the rule we mentioned above receive only 4.4.4.4/32 (which is the prefix learned via eBGP)
 
R1(config)#router ospf 1
R1(config-router)#redistribute bgp 1 subnets
 
R2#sh ip route ospf 
     4.0.0.0/32 is subnetted, 1 subnets
O E2    4.4.4.4 [110/1] via 192.168.12.1, 00:00:10, FastEthernet0/0
 
Which is true, we cannot see the 13.13.13.13/32 prefix which is learned via iBGP, now let us add the hidden command
 
R1(config-router)#router bgp 1
R1(config-router)#bgp redistribute-internal
 
R2#sh ip route ospf 
     4.0.0.0/32 is subnetted, 1 subnets
O E2    4.4.4.4 [110/1] via 192.168.12.1, 00:00:51, FastEthernet0/0
     13.0.0.0/32 is subnetted, 1 subnets
O E2    13.13.13.13 [110/1] via 192.168.12.1, 00:00:03, FastEthernet0/0
 
And yes, this command also takes the iBGP learned routes and redistributes them
 
And we can see the command as well in the show running configuration
 
R1#sh run | sec router bgp
router bgp 1
 no synchronization
 bgp log-neighbor-changes
 bgp redistribute-internal
 neighbor 3.3.3.3 remote-as 1
 neighbor 3.3.3.3 update-source Loopback0
 neighbor 192.168.14.4 remote-as 4
 no auto-summary