Monday, December 6, 2010

BGP Back Door Routes - Short Post

So in this short post I am going to discuss about BGP BackDoor Route feature.

So here is the quick topology I am going to use. The idea here is simple. R1/R2's Loopback 1 interfaces are advertised into EBGP as well as OSPF. Now by theory EBGP has lower AD of 20 Compare to OSPF AD of 110. So in that sense the route that will be installed locally in routing table of R1 & R2 will be through EBGP. But say you want to Prefer OSPF here instead of BGP for some reason. Usually Design constraints ...which are not reflecting in my topology here though :-) hehehe


Ummm....there are many ways to do it like AD manipulation and all. But another quick dirty way is configuring BGP backdoor route  feature. What essentially it does is that it instructs BGP process to allow IGP with lower AD to take precedence over EBGP learned route for same destination.


Here are quick initials:


^^^ R1 ^^^
==========


!
en
!
conf t
!
ho R1
!
line con 0
no exec-time
exit
!
int lo0
ip add 1.1.1.1 255.255.255.255
!
int lo1
ip add 11.11.11.11 255.0.0.0
ip ospf net point-to-p
exit
!
int f0/0
ip add 12.12.12.1 255.255.255.0
no sh
!
int f0/1
ip add 13.13.13.1 255.255.255.0
no sh
exit
!
ip route 2.2.2.2 255.255.255.255 f0/0 12.12.12.2
!
ip route 3.3.3.3 255.255.255.255 f0/1 13.13.13.3
!
router ospf 1
net 11.11.11.11 0.0.0.0 a 0
net 12.12.12.1 0.0.0.0 a 0
exit
!
router bgp 100
no au
no sync
net 11.0.0.0
nei 2.2.2.2 remote 200
nei 2.2.2.2 update lo0
nei 2.2.2.2 disable
nei 3.3.3.3 remote 300
nei 3.3.3.3 update lo0
nei 3.3.3.3 ebgp
exit
!
end
!
wr mem
!
=====================================================

^^^ R2 ^^^
==========

!
en
!
conf t
!
ho R2
!
line con 0
no exec-time
exit
!
int lo0
ip add 2.2.2.2 255.255.255.255
!
int lo1
ip add 22.22.22.22 255.0.0.0
exit
!
int f0/0
ip add 12.12.12.2 255.255.255.0
ip ospf net point-to-p
no sh
!
int f0/1
ip add 23.23.23.2 255.255.255.0
no sh
exit
!
ip route 1.1.1.1 255.255.255.255 f0/0 12.12.12.1
!
ip route 3.3.3.3 255.255.255.255 f0/1 23.23.23.3
!
router ospf 1
net 22.22.22.22 0.0.0.0 a 0
net 12.12.12.2 0.0.0.0 a 0
exit
!
router bgp 200
no au
no sync
net 22.0.0.0
nei 1.1.1.1 remote 100
nei 1.1.1.1 update lo0
nei 1.1.1.1 disable
nei 3.3.3.3 remote 300
nei 3.3.3.3 update lo0
nei 3.3.3.3 ebgp
exit
!
end
!
wr mem
!
=================================================

^^^ R3 ^^^
==========

!
en
!
conf t
!
ho R3
!
line con 0
no exec-time
exit
!
int lo0
ip add 3.3.3.3 255.255.255.255
!
int lo1
ip add 33.33.33.33 255.0.0.0
exit
!
int f0/0
ip add 13.13.13.3 255.255.255.0
no sh
!
int f0/1
ip add 23.23.23.3 255.255.255.0
no sh
exit
!
ip route 1.1.1.1 255.255.255.255 f0/0 13.13.13.1
!
ip route 3.3.3.3 255.255.255.255 f0/1 23.23.23.2
!
router bgp 300
no au
no sync
net 33.0.0.0
nei 1.1.1.1 remote 100
nei 1.1.1.1 update lo0
nei 1.1.1.1 disable
nei 2.2.2.2 remote 200
nei 2.2.2.2 update lo0
nei 2.2.2.2 ebgp
exit
!
end
!
wr mem
!

#########################

Lets check routing table of R1 and R2:


R1#sh ip ro | b ^G
Gateway of last resort is not set


     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
     2.0.0.0/32 is subnetted, 1 subnets
S       2.2.2.2 [1/0] via 12.12.12.2, FastEthernet0/0
B    33.0.0.0/8 [20/0] via 3.3.3.3, 01:04:55
     3.0.0.0/32 is subnetted, 1 subnets
S       3.3.3.3 [1/0] via 13.13.13.3, FastEthernet0/1
B    22.0.0.0/8 [20/0] via 2.2.2.2, 00:46:54
C    11.0.0.0/8 is directly connected, Loopback1
     12.0.0.0/24 is subnetted, 1 subnets
C       12.12.12.0 is directly connected, FastEthernet0/0
     13.0.0.0/24 is subnetted, 1 subnets
C       13.13.13.0 is directly connected, FastEthernet0/1


R2#sh ip route | b ^G
Gateway of last resort is not set

     1.0.0.0/32 is subnetted, 1 subnets
S       1.1.1.1 [1/0] via 12.12.12.1, FastEthernet0/0
     2.0.0.0/32 is subnetted, 1 subnets
C       2.2.2.2 is directly connected, Loopback0
B    33.0.0.0/8 [20/0] via 1.1.1.1, 01:05:28
     3.0.0.0/32 is subnetted, 1 subnets
S       3.3.3.3 [1/0] via 23.23.23.3, FastEthernet0/1
     23.0.0.0/24 is subnetted, 1 subnets
C       23.23.23.0 is directly connected, FastEthernet0/1
C    22.0.0.0/8 is directly connected, Loopback1
B    11.0.0.0/8 [20/0] via 1.1.1.1, 01:08:49
     12.0.0.0/24 is subnetted, 1 subnets
C       12.12.12.0 is directly connected, FastEthernet0/0

Now lets see if ospf has same route in database:

R1#sh ip ospf database router | b 22
  Link State ID: 22.22.22.22
  Advertising Router: 22.22.22.22
  LS Seq Number: 80000004
  Checksum: 0x24DF
  Length: 48
  Number of Links: 2

    Link connected to: a Transit Network
     (Link ID) Designated Router address: 12.12.12.1
     (Link Data) Router Interface address: 12.12.12.2
      Number of TOS metrics: 0
       TOS 0 Metrics: 10

    Link connected to: a Stub Network
     (Link ID) Network/subnet number: 22.0.0.0
     (Link Data) Network Mask: 255.0.0.0
      Number of TOS metrics: 0
       TOS 0 Metrics: 1

R2#sh ip ospf database

            OSPF Router with ID (22.22.22.22) (Process ID 1)

Router Link States (Area 0)

Link ID         ADV Router      Age         Seq#       Checksum Link count
11.11.11.11     11.11.11.11     1197        0x80000004 0x008BDC 2
22.22.22.22     22.22.22.22     1056        0x80000004 0x0024DF 2

Net Link States (Area 0)

Link ID         ADV Router      Age         Seq#       Checksum
12.12.12.1      11.11.11.11     443         0x80000003 0x005C06

Now lets configure BGP backdoor feature and see the differences in the routing table:

R1(config)#router bgp 100
R1(config-router)#network 22.0.0.0 backdoor
R1(config-router)#exit

R2(config)#router bgp 200
R2(config-router)#net 11.0.0.0 backdoor
R2(config-router)#exit

R1#sh ip ro | b ^G
Gateway of last resort is not set

     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
     2.0.0.0/32 is subnetted, 1 subnets
S       2.2.2.2 [1/0] via 12.12.12.2, FastEthernet0/0
B    33.0.0.0/8 [20/0] via 3.3.3.3, 01:09:45
     3.0.0.0/32 is subnetted, 1 subnets
S       3.3.3.3 [1/0] via 13.13.13.3, FastEthernet0/1
O    22.0.0.0/8 [110/11] via 12.12.12.2, 00:01:01, FastEthernet0/0
C    11.0.0.0/8 is directly connected, Loopback1
     12.0.0.0/24 is subnetted, 1 subnets
C       12.12.12.0 is directly connected, FastEthernet0/0
     13.0.0.0/24 is subnetted, 1 subnets
C       13.13.13.0 is directly connected, FastEthernet0/1


R2#sh ip ro | b ^G
Gateway of last resort is not set

     1.0.0.0/32 is subnetted, 1 subnets
S       1.1.1.1 [1/0] via 12.12.12.1, FastEthernet0/0
     2.0.0.0/32 is subnetted, 1 subnets
C       2.2.2.2 is directly connected, Loopback0
B    33.0.0.0/8 [20/0] via 1.1.1.1, 01:10:03
     3.0.0.0/32 is subnetted, 1 subnets
S       3.3.3.3 [1/0] via 23.23.23.3, FastEthernet0/1
     23.0.0.0/24 is subnetted, 1 subnets
C       23.23.23.0 is directly connected, FastEthernet0/1
C    22.0.0.0/8 is directly connected, Loopback1
O    11.0.0.0/8 [110/11] via 12.12.12.1, 00:00:47, FastEthernet0/0
     12.0.0.0/24 is subnetted, 1 subnets
C       12.12.12.0 is directly connected, FastEthernet0/0


HTH...
Deepak Arora

No comments: