Wednesday, 28 December 2016

BGP CHAPTER 9 (REG-EX)

BGP CHAPTER 9 (REG-EX)
QUESTIONS:
18. Short notes on regular-expressions .
19. lab:for ISP1 it will not accept AS300 prefix, for ISP2 it will not accept AS200 prefix.
20. lab: back-to-back connection between ISP1-ISP2, but ISP1 it will learn 150.1.0.0/24
prefixes via NLFAST ISP to ISP2 to ISP1.(use reg-exp to perform these tasks)
Solution:
18. Short notes on regular-expressions .

Regular expression:
commonly in BGP for matching items in as-path.
^ Maches the beginning of input
$ matches end
| or 
. Matches a single character
+ Matches the character to the left or more times
* Matches the character to the left 0 or more times
? Mathes the character to the left 0 or 1 times
\ Removes special meanings
() Affects order of operations
[] Creates a group of characters
_ white space

19. lab:for ISP1 it will not accept AS300 prefix, for ISP2 it will not accept AS200 prefix
---->

refer the diagram:
initially ISP1 learning the prefixes: from R1
ISP1(config-if)#do sh ip bgp
-----output cut
   Network          Next Hop            Metric LocPrf Weight Path
*> 11.1.1.1/32      0.0.0.0                  0         32768 ?
*> 11.1.1.2/32      0.0.0.0                  0         32768 ?
*> 11.1.1.3/32      0.0.0.0                  0         32768 ?
*> 22.1.1.1/32      1.1.1.1                                0 1234 300 ?
*> 22.1.1.2/32      1.1.1.1                                0 1234 300 ?
*> 22.1.1.3/32      1.1.1.1                                0 1234 300 ?
*> 150.1.0.0/24     1.1.1.1                  0             0 1234 i
*> 150.1.1.0/24     1.1.1.1                                0 1234 i

after applying policy on R1 in outward direction :
R1(config-router)#do sh run | se ip as-path
!
ip as-path access-list 1 deny _300_
ip as-path access-list 1 permit .*
!
 sh run | se route-map DAS300
route-map DAS300 permit 10
 match as-path 1
 !
 router bgp 1234
 neighbor 11.1.1.1 route-map DAS300 out
!
output at ISP1
!
ISP1(config-if)#do sh ip bgp
BGP table version is 16, local router ID is 11.1.1.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
*> 11.1.1.1/32      0.0.0.0                  0         32768 ?
*> 11.1.1.2/32      0.0.0.0                  0         32768 ?
*> 11.1.1.3/32      0.0.0.0                  0         32768 ?
*> 150.1.0.0/24     1.1.1.1                  0             0 1234 i
*> 150.1.1.0/24     1.1.1.1                                0 1234 i

because we have filtered AS300.
apply same policy to R2 for AS200.

R1(config-router)#do sh run | se ip as-path
!
ip as-path access-list 1 deny _200_
ip as-path access-list 1 permit .*
!
 !sh run | se route-map DAS200
route-map DAS300 permit 10
 match as-path 1
 !
 router bgp 1234
 neighbor 22.1.1.1 route-map DAS300 out
!
output at ISP2
!
 ISP2#sh ip bgp
BGP table version is 22, local router ID is 22.1.1.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
*> 22.1.1.1/32      0.0.0.0                  0         32768 ?
*> 22.1.1.2/32      0.0.0.0                  0         32768 ?
*> 22.1.1.3/32      0.0.0.0                  0         32768 ?
*> 150.1.0.0/24     2.2.2.2                  0             0 1234 i
*> 150.1.1.0/24     2.2.2.2                                0 1234 i
not receiving routes from ISP1.

20. lab: back-to-back connection between ISP1-ISP2, but ISP1 it will learn 150.1.0.0/24
prefixes via NLFAST ISP to ISP2 to ISP1.(use reg-exp to perform these tasks)
---> refer diagram:

create ebgp relationship between ISP1 & ISP2 back2back link.

for ISP1:
ISP1# sh ip bgp
--- output cut ---- it is learning 150.1.0.0 prefix via R1 , but i want it learn
via 199.9.9.2???
*  150.1.0.0/24     199.9.9.2                              0 300 1234 i
*>                  1.1.1.1                  0             0 1234 i
*  150.1.1.0/24     199.9.9.2                              0 300 1234 i
*>                  1.1.1.1                                0 1234 i
we can increase the weight on ISP1 while it receive the prefix from ISP2.

ISP1(config-router)#do sh run | se ip as-path
ip as-path access-list 100 permit _1234_
!
ISP1(config-router)#do sh run | se route-map
!
route-map VIAISP2 permit 10
 match as-path 100
 set weight 2000
route-map VIAISP2 permit 20
!
ISP1(config-router)#do sh run | se bgp
router bgp 200
 neighbor 199.9.9.2 route-map VIAISP2 in
!
ISP1(config-router)#do sh ip bgp
BGP table version is 27, local router ID is 11.1.1.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
*> 11.1.1.1/32      0.0.0.0                  0         32768 ?
*> 11.1.1.2/32      0.0.0.0                  0         32768 ?
*> 11.1.1.3/32      0.0.0.0                  0         32768 ?
*> 22.1.1.1/32      199.9.9.2                0             0 300 ?
*> 22.1.1.2/32      199.9.9.2                0             0 300 ?
*> 22.1.1.3/32      199.9.9.2                0             0 300 ?
*> 150.1.0.0/24     199.9.9.2                           2000 300 1234 i
*                   1.1.1.1                  0             0 1234 i
*> 150.1.1.0/24     199.9.9.2                           2000 300 1234 i
*                   1.1.1.1                                0 1234 i

now we can see ISP2 prefers 150.1.0.0 network . WoW !!!!!

No comments:

Post a Comment