Wednesday, January 18, 2012

BGP NEXT HOP PROCESSING

BGP NEXT HOP PROCESSING
------------------------
IN EBGP relationship the next hop is changed
For a IBGP relationship the next hop is not changed

LAB
---


Best way to look at this is in lab
r5
===
r5#sh ip
*Jan 18 19:17:03.871: %SYS-5-CONFIG_I: Configured from console by console bgp
BGP table version is 4, local router ID is 5.5.5.5
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
*> 4.4.4.4/32       172.25.13.4              0             0 64512 i
r5#

ok so we recieved the route 4.4.4.4 from ebgp with next hop of 172.25.13.4
lets take a look at
r4
---
switch1#sh ip bgp
BGP table version is 6, 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
* i4.4.4.4/32       172.25.13.4              0    100      0 64512 i
switch1#
via IBGP the next hop has not changed it is still 172.25.13.4 this is not being put in the routing table we are not seeing >
witch1#sh ip bgp 4.4.4.4
BGP routing table entry for 4.4.4.4/32, version 6
Paths: (1 available, no best path)
  Not advertised to any peer
  64512
    172.25.13.4 (inaccessible) from 5.5.5.5 (5.5.5.5)
      Origin IGP, metric 0, localpref 100, valid, internal
switch1#

We have 1 availble 1 path but as 172.25.13.4 is inaccessible

switch1#ping 172.25.13.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.25.13.4, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
switch1#sh ip route 172.25.13.4
% Network not in table
switch1#

SO we have an issue there is a few ways of resolving this

probably the easiest is to advertise 172.25.13.0 by eigrp or bgp will do either  on r5

r5
---
router eigrp 1
 network 5.5.5.5 0.0.0.0
 network 10.164.49.0 0.0.0.255
 network 10.229.254.0 0.0.0.255
 network 172.25.13.0 0.0.0.255

r4
---
switch1#sh ip bgp
BGP table version is 7, 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
*>i4.4.4.4/32       172.25.13.4              0    100      0 64512 i
switch1#

route is now valid on r4
switch1#ping 4.4.4.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/3/8 ms
switch1#

ok lets look at another option
on r5
-------

r5(config-router)#router bgp 64513
r5(config-router)#neighbor 1.1.1.1 next-hop-self
r5(config-router)#

r4
--

switch1#sh ip bgp
00:40:42: %SYS-5-CONFIG_I: Configured from console by console
BGP table version is 9, 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
*>i4.4.4.4/32       5.5.5.5                  0    100      0 64512 i
switch1#

notice now the next hop has changed to r5 5.5.5.5 and we have valid route which was selected as best

switch1#ping 4.4.4.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/4/9 ms
switch1#

we can ping ok

lets try another option
on r5 ihave created a route-map
r5#sh route-map
route-map SET_NEXTHOP, permit, sequence 10
  Match clauses:
  Set clauses:
    ip next-hop 5.5.5.5
  Policy routing matches: 0 packets, 0 bytes
r5#
router bgp 64513
 neighbor 1.1.1.1 route-map SET_NEXTHOP out

s1
---

switch1#sh ip bgp
BGP table version is 11, 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
*>i4.4.4.4/32       5.5.5.5                  0    100      0 64512 i
switch1#


switch1#ping 4.4.4.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/8 ms
switch1#

we are able to ping

We can get into more flexible scenerios with the route-map set-nexthop
One of the issues with BGP is that it is slow we could lower the timers to get quicker failover
but this may cause to much additional processing or may not be an option as we may control AS 64513
but not control AS 64512 for example. Imagine in this scenerio we have another EBGP connection to
another AS (service provider). If the link between r4 and r5 we want the ibgp routes to be pulled from
s1 asap rather than waiting the hold time 180 for ebgp.
Lets take a look at how we could do this

r5
---
We define a ip sla
r5(config-ip-sla)#ip sla 1
r5(config-ip-sla)#icmp-echo 172.25.13.4
r5(config-ip-sla-echo)#frequency 5
r5(config-ip-sla-echo)#timeout 2000
r5(config-ip-sla-echo)#exit
we will schedule it for now
r5(config)#ip sla schedule 1 start now life forever
we will now create a enhanced object tracking to look of the result of the ipsla
r5(config)#track 1 rtr 1
r5(config-track)#exit
r5(config)#

we will create a place holder route with the track attached
r5(config)#ip route 169.255.0.1 255.255.255.255 null 0 track 1
r5(config)#

Now we will redistribute the route into eigrp

r5(config)#router eigrp 1
r5(config-router)#redistribute static metric 100 100 100 100 100
r5(config-router)#

Lets now create a route map to change next hop

r5(config)#route-map CHANGE-NEXT
r5(config-route-map)#set ip next-hop 169.255.0.1
r5(config-route-map)#exit

now lets tie it to the neighbor
r5(config)#router bgp 64513
r5(config-router)#neighbor 1.1.1.1 route-map CHANGE-NEXT out


s1#sh ip bgp
BGP table version is 2, 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
*>i4.4.4.4/32       169.255.0.1              0    100      0 64512 i
s1#

we can see now we have valid next hop router in the bgp table of 4.4.4.4 with next hop of 169.255.0.1
it is also in the routing table
s1#sh ip route bgp
     4.0.0.0/32 is subnetted, 1 subnets
B       4.4.4.4 [200/0] via 169.255.0.1, 00:02:48
s1#
and we can ping
s1#ping 4.4.4.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 28/48/68 ms

now lets take a look what happens if we shutdown r4 int
the track on r5 goes down
*Mar  1 00:46:12.319: %TRACKING-5-STATE: 1 rtr 1 state Up->Do

which removes the route  169.255.0.1 from the routing table which in turns makes the route via 4.4.4.4 invalid  if we were
recieving 4.4.4.4 from alternative path this would take preference all this would happen alot quicker than waiting on the bgp timers

No comments:

Post a Comment