My Countingdown

Showing posts with label BGP. Show all posts
Showing posts with label BGP. Show all posts

Thursday, December 15, 2011

Lab 11. BGP using AS-PATH


Now, let’s use AS-PATH for influencing path selection from R100 to R500.

Let’s make the lab

R1#
interface loopback 0
  ip address 1.1.1.1 255.255.255.255
interface f0/0
  ip address 14.14.14.1 255.255.255.0
  no shu
interface f0/1
  ip address 12.12.12.1 255.255.255.0
  no shu
interface s0/0
  ip address 110.110.110.1 255.255.255.0
  no shut
router bgp 12
  neighbor 12.12.12.2 remote-as 12
  neighbor 12.12.12.2 next-hop-self
  neighbor 14.14.14.4 remote-as 34
  neighbor 110.110.110.10 remote-as 100
  network 1.1.1.1 mask 255.255.255.255

R2#
interface loopback 0
  ip address 2.2.2.2 255.255.255.255
interface f0/0
  ip address 23.23.23.2 255.255.255.0
  no shu
interface f0/1
  ip address 12.12.12.2 255.255.255.0
  no shu
router bgp 12
  neighbor 12.12.12.1 remote-as 12
  neighbor 12.12.12.1 next-hop-self
  neighbor 23.23.23.3 remote-as 34
  network 2.2.2.2 mask 255.255.255.255
 
R3#
interface loopback 0
  ip address 3.3.3.3 255.255.255.255
interface f0/0
  ip address 23.23.23.3 255.255.255.0
  no shu
interface f0/1
  ip address 34.34.34.3 255.255.255.0
  no shu
router bgp 34
  neighbor 23.23.23.2 remote-as 12
  neighbor 34.34.34.4 remote-as 34
  neighbor 34.34.34.4 next-hop-self
  network 3.3.3.3 mask 255.255.255.255

R4#
interface loopback 0
  ip address 4.4.4.4 255.255.255.255
interface f0/0
  ip address 14.14.14.4 255.255.255.0
  no shu
interface f0/1
  ip address 34.34.34.4 255.255.255.0
  no shu
interface s0/0
  ip address 150.150.150.4 255.255.255.0
  no shut
router bgp 34
  neighbor 14.14.14.1 remote-as 12
  neighbor 34.34.34.3 remote-as 34
  neighbor 34.34.34.3 next-hop-self
  neighbor 150.150.150.50 remote-as 500
  network 4.4.4.4 mask 255.255.255.255

R100#
interface loopback 0
  ip address 10.10.10.10 255.255.255.255
interface s0/0
  ip address 110.110.110.10 255.255.255.0
  no shut
router bgp 100
  neighbor 110.110.110.1 remote-as 12
  network 10.10.10.10 mask 255.255.255.255

R500#
interface loopback 0
  ip address 50.50.50.50 255.255.255.255
interface s0/0
  ip address 150.150.150.50 255.255.255.0
  no shut
router bgp 500
  neighbor 150.150.150.4 remote-as 34
  network 50.50.50.50 mask 255.255.255.255

Let’s check routing table to R500 in R1

R1(config-router)#do sh ip bgp 50.50.50.50
BGP routing table entry for 50.50.50.50/32, version 7
Paths: (2 available, best #2, table Default-IP-Routing-Table)
  Advertised to update-groups:
        1    2
  34 500
    12.12.12.2 from 12.12.12.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, internal
  34 500
    14.14.14.4 from 14.14.14.4 (4.4.4.4)
      Origin IGP, localpref 100, valid, external, best    --- > best path by default

Let’s check BGP path selection to R500

R100(config-router)#do tracer 50.50.50.50 sour 10.10.10.10
Type escape sequence to abort.
Tracing the route to 50.50.50.50

  1 110.110.110.1 4 msec 72 msec 68 msec
  2 14.14.14.4 60 msec 48 msec 88 msec
  3 150.150.150.50 160 msec *  60 msec

Now let’s use AS-PATH

R4#
router bgp 34
  neighbor 14.14.14.1 route-map AS_PATH_OUT out

route-map AS_PATH_OUT
  set as-path prepend 34 34 34

Then do clear ip bgp to change routing for path selection. Let’s check in R1.

R1(config-router)#do sh ip bgp 50.50.50.50
BGP routing table entry for 50.50.50.50/32, version 26
Paths: (2 available, best #1, table Default-IP-Routing-Table)
Flag: 0x820
  Advertised to update-groups:
        1
  34 500
    12.12.12.2 from 12.12.12.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, internal, best   ---> best path after change AS-PATH
  34 34 34 34 500          --- > the AS-PATH will be long so will not choose
    14.14.14.4 from 14.14.14.4 (4.4.4.4)
      Origin IGP, localpref 100, valid, external

R1(config-router)#do sh ip bgp
BGP table version is 27, 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
*> 1.1.1.1/32       0.0.0.0                  0         32768 i
*>i2.2.2.2/32       12.12.12.2               0    100      0 i
*  3.3.3.3/32       14.14.14.4                             0 34 34 34 34 i
*>i                 12.12.12.2               0    100      0 34 i
*  4.4.4.4/32       14.14.14.4               0             0 34 34 34 34 i
*>i                 12.12.12.2               0    100      0 34 i
*> 10.10.10.10/32   110.110.110.10           0             0 100 i
*>i50.50.50.50/32   12.12.12.2               0    100      0 34 500 i
*                   14.14.14.4                             0 34 34 34 34 500 i

Make sure the trace route via R1>R2>R3>R4.

R100(config)#do tracer 50.50.50.50 sour 10.10.10.10
Type escape sequence to abort.
Tracing the route to 50.50.50.50

  1 110.110.110.1 4 msec 12 msec 24 msec
  2 12.12.12.2 68 msec 112 msec 84 msec
  3 23.23.23.3 104 msec 120 msec 36 msec
  4 34.34.34.4 108 msec 76 msec 104 msec
  5 150.150.150.50 80 msec *  124 msec

Lab 10. BGP using MED


Now, we’ll try to do lab using MED. MED is used to influence outbound traffic. For example this lab if we see R100 to R500 will go via R1 and R4 because the AS Path is smaller than other way with assumption all marks is default. Please refer to BGP summary regarding path selection in BGP! http://pursuingmydestiny.blogspot.com/2011/12/bgp-summary.html

Let’s make the lab

R1#
interface loopback 0
  ip address 1.1.1.1 255.255.255.255
interface f0/0
  ip address 14.14.14.1 255.255.255.0
  no shu
interface f0/1
  ip address 12.12.12.1 255.255.255.0
  no shu
interface s0/0
  ip address 110.110.110.1 255.255.255.0
  no shut
router bgp 12
  neighbor 12.12.12.2 remote-as 12
  neighbor 12.12.12.2 next-hop-self
  neighbor 14.14.14.4 remote-as 34
  neighbor 110.110.110.10 remote-as 100
  network 1.1.1.1 mask 255.255.255.255

R2#
interface loopback 0
  ip address 2.2.2.2 255.255.255.255
interface f0/0
  ip address 23.23.23.2 255.255.255.0
  no shu
interface f0/1
  ip address 12.12.12.2 255.255.255.0
  no shu
router bgp 12
  neighbor 12.12.12.1 remote-as 12
  neighbor 12.12.12.1 next-hop-self
  neighbor 23.23.23.3 remote-as 34
  network 2.2.2.2 mask 255.255.255.255
 
R3#
interface loopback 0
  ip address 3.3.3.3 255.255.255.255
interface f0/0
  ip address 23.23.23.3 255.255.255.0
  no shu
interface f0/1
  ip address 34.34.34.3 255.255.255.0
  no shu
router bgp 34
  neighbor 23.23.23.2 remote-as 12
  neighbor 34.34.34.4 remote-as 34
  neighbor 34.34.34.4 next-hop-self
  network 3.3.3.3 mask 255.255.255.255

R4#
interface loopback 0
  ip address 4.4.4.4 255.255.255.255
interface f0/0
  ip address 14.14.14.4 255.255.255.0
  no shu
interface f0/1
  ip address 34.34.34.4 255.255.255.0
  no shu
interface s0/0
  ip address 150.150.150.4 255.255.255.0
  no shut
router bgp 34
  neighbor 14.14.14.1 remote-as 12
  neighbor 34.34.34.3 remote-as 34
  neighbor 34.34.34.3 next-hop-self
  neighbor 150.150.150.50 remote-as 500
  network 4.4.4.4 mask 255.255.255.255

R100#
interface loopback 0
  ip address 10.10.10.10 255.255.255.255
interface s0/0
  ip address 110.110.110.10 255.255.255.0
  no shut
router bgp 100
  neighbor 110.110.110.1 remote-as 12
  network 10.10.10.10 mask 255.255.255.255

R500#
interface loopback 0
  ip address 50.50.50.50 255.255.255.255
interface s0/0
  ip address 150.150.150.50 255.255.255.0
  no shut
router bgp 500
  neighbor 150.150.150.4 remote-as 34
  network 50.50.50.50 mask 255.255.255.255

Let’s check routing table to R500 in R1

R1(config-router)#do sh ip bgp 50.50.50.50
BGP routing table entry for 50.50.50.50/32, version 7
Paths: (2 available, best #2, table Default-IP-Routing-Table)
  Advertised to update-groups:
        1    2
  34 500
    12.12.12.2 from 12.12.12.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, internal
  34 500
    14.14.14.4 from 14.14.14.4 (4.4.4.4)
      Origin IGP, localpref 100, valid, external, best   --- > best path choose by default

Let’s check BGP path selection from R100 to R500

R100(config-router)#do tracer 50.50.50.50 sour 10.10.10.10
Type escape sequence to abort.
Tracing the route to 50.50.50.50

  1 110.110.110.1 4 msec 72 msec 68 msec
  2 14.14.14.4 60 msec 48 msec 88 msec
  3 150.150.150.50 160 msec *  60 msec

So let’s make change path selection from R100 to R500 via R1>R2>R3>R4…
There are 2 solution by influencing inbound traffic
  1. Using MED attribute. Lowest MED will be preferred
  2. Using AS-PATH. Shortest AS-PATH will be preferred
Let’s use MED first. Using weight & local preference applied in R1 but using MED & AS-PATH applied in R4. Ask your self, why like that??? J 

R4#
router bgp 34
  neighbor 14.14.14.1 route-map MED_OUT out

route-map MED_OUT
  set metric 200

Then do clear ip bgp to change routing for path selection. Let’s check in R1. Why in R1??? Because MED influence inbound traffic to R3 from R1. So it will change best path selection in R1 to R500.

R1(config-router)#do sh ip bgp 50.50.50.50
BGP routing table entry for 50.50.50.50/32, version 14
Paths: (2 available, best #1, table Default-IP-Routing-Table)
Flag: 0x4860
  Not advertised to any peer
  34 500
    12.12.12.2 from 12.12.12.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, internal, best
  34 500
    14.14.14.4 from 14.14.14.4 (4.4.4.4)
      Origin IGP, metric 200, localpref 100, valid, external

Make sure the trace route is via R1>R2>R3>R4

R100(config-router)#do tracer 50.50.50.50 sour 10.10.10.10
Type escape sequence to abort.
Tracing the route to 50.50.50.50

  1 110.110.110.1 0 msec 108 msec 0 msec
  2 12.12.12.2 96 msec 48 msec 76 msec
  3 23.23.23.3 156 msec 92 msec 108 msec
  4 34.34.34.4 112 msec 180 msec 76 msec
  5 150.150.150.50 192 msec *  84 msec

Lab 9. BGP using Local Preference


We already did using weight to influence outbound traffic from R100 to R500 via R1>R2>R3>R4. Now let’s try using local preference.

R1#
interface loopback 0
  ip address 1.1.1.1 255.255.255.255
interface f0/0
  ip address 14.14.14.1 255.255.255.0
  no shu
interface f0/1
  ip address 12.12.12.1 255.255.255.0
  no shu
interface s0/0
  ip address 110.110.110.1 255.255.255.0
  no shut
router bgp 12
  neighbor 12.12.12.2 remote-as 12
  neighbor 12.12.12.2 next-hop-self
  neighbor 14.14.14.4 remote-as 34
  neighbor 110.110.110.10 remote-as 100
  network 1.1.1.1 mask 255.255.255.255

R2#
interface loopback 0
  ip address 2.2.2.2 255.255.255.255
interface f0/0
  ip address 23.23.23.2 255.255.255.0
  no shu
interface f0/1
  ip address 12.12.12.2 255.255.255.0
  no shu
router bgp 12
  neighbor 12.12.12.1 remote-as 12
  neighbor 12.12.12.1 next-hop-self
  neighbor 23.23.23.3 remote-as 34
  network 2.2.2.2 mask 255.255.255.255
 
R3#
interface loopback 0
  ip address 3.3.3.3 255.255.255.255
interface f0/0
  ip address 23.23.23.3 255.255.255.0
  no shu
interface f0/1
  ip address 34.34.34.3 255.255.255.0
  no shu
router bgp 34
  neighbor 23.23.23.2 remote-as 12
  neighbor 34.34.34.4 remote-as 34
  neighbor 34.34.34.4 next-hop-self
  network 3.3.3.3 mask 255.255.255.255

R4#
interface loopback 0
  ip address 4.4.4.4 255.255.255.255
interface f0/0
  ip address 14.14.14.4 255.255.255.0
  no shu
interface f0/1
  ip address 34.34.34.4 255.255.255.0
  no shu
interface s0/0
  ip address 150.150.150.4 255.255.255.0
  no shut
router bgp 34
  neighbor 14.14.14.1 remote-as 12
  neighbor 34.34.34.3 remote-as 34
  neighbor 34.34.34.3 next-hop-self
  neighbor 150.150.150.50 remote-as 500
  network 4.4.4.4 mask 255.255.255.255

R100#
interface loopback 0
  ip address 10.10.10.10 255.255.255.255
interface s0/0
  ip address 110.110.110.10 255.255.255.0
  no shut
router bgp 100
  neighbor 110.110.110.1 remote-as 12
  network 10.10.10.10 mask 255.255.255.255

R500#
interface loopback 0
  ip address 50.50.50.50 255.255.255.255
interface s0/0
  ip address 150.150.150.50 255.255.255.0
  no shut
router bgp 500
  neighbor 150.150.150.4 remote-as 34
  network 50.50.50.50 mask 255.255.255.255

Let’s check routing table to R500 in R1

R1(config-router)#do sh ip bgp 50.50.50.50
BGP routing table entry for 50.50.50.50/32, version 7
Paths: (2 available, best #2, table Default-IP-Routing-Table)
  Advertised to update-groups:
        1    2
  34 500
    12.12.12.2 from 12.12.12.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, internal
  34 500
    14.14.14.4 from 14.14.14.4 (4.4.4.4)
      Origin IGP, localpref 100, valid, external, best    ---- > best path to go to 50.50.50.50 from R1

Let’s check BGP path selection to R500

R100(config-router)#do tracer 50.50.50.50 sour 10.10.10.10
Type escape sequence to abort.
Tracing the route to 50.50.50.50

  1 110.110.110.1 4 msec 72 msec 68 msec
  2 14.14.14.4 60 msec 48 msec 88 msec
  3 150.150.150.50 160 msec *  60 msec

Let’s use local preference so traffic to R500 will route via R1>R2>R3>R4 from R100

R1#
router bgp 12
   neighbor 12.12.12.2 route-map LOCAL_PREF in

route-map LOCAL_PREF permit 10
  set local-preference 200

Again you need to clear ip bgp first to get new change BGP best path. Please be patient this is BGP bro!

R1(config-route-map)#do clear ip bgp *

Let’s check the path selection already change via R2.

R1(config-route-map)#do sh ip bgp 50.50.50.50
BGP routing table entry for 50.50.50.50/32, version 7
Paths: (2 available, best #2, table Default-IP-Routing-Table)
Flag: 0x820
  Advertised to update-groups:
        1
  34 500
    14.14.14.4 from 14.14.14.4 (4.4.4.4)
      Origin IGP, localpref 100, valid, external
  34 500
    12.12.12.2 from 12.12.12.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 200, valid, internal, best

Make sure trace route from R100 to R500 via R1>R2>R3>R4

R100(config-router)#do tracer 50.50.50.50 sour 10.10.10.10
Type escape sequence to abort.
Tracing the route to 50.50.50.50

  1 110.110.110.1 48 msec 92 msec 16 msec
  2 12.12.12.2 32 msec 92 msec 92 msec
  3 23.23.23.3 128 msec 104 msec 156 msec
  4 34.34.34.4 32 msec 108 msec 124 msec
  5 150.150.150.50 40 msec *  108 msec

Lab 8. BGP using Weight


Now, we’ll try to do lab using Weight. Weight is Cisco proprietary. Wight is used to influence outbound traffic. For example this lab if we see R100 to R500 will go via R1 and R4 because the AS Path is smaller than other way with assumption all mark is default. Please refer to BGP summary regarding path selection in BGP! --> http://pursuingmydestiny.blogspot.com/2011/12/bgp-summary.html

Let’s make the lab

R1#
interface loopback 0
  ip address 1.1.1.1 255.255.255.255
interface f0/0
  ip address 14.14.14.1 255.255.255.0
  no shu
interface f0/1
  ip address 12.12.12.1 255.255.255.0
  no shu
interface s0/0
  ip address 110.110.110.1 255.255.255.0
  no shut
router bgp 12
  neighbor 12.12.12.2 remote-as 12
  neighbor 12.12.12.2 next-hop-self
  neighbor 14.14.14.4 remote-as 34
  neighbor 110.110.110.10 remote-as 100
  network 1.1.1.1 mask 255.255.255.255

R2#
interface loopback 0
  ip address 2.2.2.2 255.255.255.255
interface f0/0
  ip address 23.23.23.2 255.255.255.0
  no shu
interface f0/1
  ip address 12.12.12.2 255.255.255.0
  no shu
router bgp 12
  neighbor 12.12.12.1 remote-as 12
  neighbor 12.12.12.1 next-hop-self
  neighbor 23.23.23.3 remote-as 34
  network 2.2.2.2 mask 255.255.255.255
 
R3#
interface loopback 0
  ip address 3.3.3.3 255.255.255.255
interface f0/0
  ip address 23.23.23.3 255.255.255.0
  no shu
interface f0/1
  ip address 34.34.34.3 255.255.255.0
  no shu
router bgp 34
  neighbor 23.23.23.2 remote-as 12
  neighbor 34.34.34.4 remote-as 34
  neighbor 34.34.34.4 next-hop-self
  network 3.3.3.3 mask 255.255.255.255

R4#
interface loopback 0
  ip address 4.4.4.4 255.255.255.255
interface f0/0
  ip address 14.14.14.4 255.255.255.0
  no shu
interface f0/1
  ip address 34.34.34.4 255.255.255.0
  no shu
interface s0/0
  ip address 150.150.150.4 255.255.255.0
  no shut
router bgp 34
  neighbor 14.14.14.1 remote-as 12
  neighbor 34.34.34.3 remote-as 34
  neighbor 34.34.34.3 next-hop-self
  neighbor 150.150.150.50 remote-as 500
  network 4.4.4.4 mask 255.255.255.255

R100#
interface loopback 0
  ip address 10.10.10.10 255.255.255.255
interface s0/0
  ip address 110.110.110.10 255.255.255.0
  no shut
router bgp 100
  neighbor 110.110.110.1 remote-as 12
  network 10.10.10.10 mask 255.255.255.255

R500#
interface loopback 0
  ip address 50.50.50.50 255.255.255.255
interface s0/0
  ip address 150.150.150.50 255.255.255.0
  no shut
router bgp 500
  neighbor 150.150.150.4 remote-as 34
  network 50.50.50.50 mask 255.255.255.255

Let’s check routing table to R500 in R1

R1(config-router)#do sh ip bgp 50.50.50.50
BGP routing table entry for 50.50.50.50/32, version 7
Paths: (2 available, best #2, table Default-IP-Routing-Table)
  Advertised to update-groups:
        1    2
  34 500
    12.12.12.2 from 12.12.12.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, internal
  34 500
    14.14.14.4 from 14.14.14.4 (4.4.4.4)
      Origin IGP, localpref 100, valid, external, best           --- > by default will choose via R1-R4

Let’s check trace route from R100 to R500

R100(config-router)#do tracer 50.50.50.50 sour 10.10.10.10
Type escape sequence to abort.
Tracing the route to 50.50.50.50

  1 110.110.110.1 4 msec 72 msec 68 msec
  2 14.14.14.4 60 msec 48 msec 88 msec
  3 150.150.150.50 160 msec *  60 msec

So let’s make change path selection from R100 to R500 via R1>R2>R3>R4…
There are 2 solution by influencing outbound traffic
  1. Using weight attribute. Highest weight will be preferred
  2. Using local preference. Highest local preference will be preferred
Let’s use weight first

R1#
router bgp 12
   neighbor 12.12.12.2 route-map WEIGHT_IN in

route-map WEIGHT_IN permit 10
  set weight 100

Now let’s check best path in R1 to R500 and trace route to make sure that the traffic to R500 via R1>R2>R3>R4

If the BGP routing table is not change, please do not be panic J Clear ip bgp first to get new change BGP best path

R1(config-route-map)#do clear ip bgp *

R1(config-route-map)#do sh ip bgp 50.50.50.50
BGP routing table entry for 50.50.50.50/32, version 7
Paths: (2 available, best #2, table Default-IP-Routing-Table)
Flag: 0x820
  Advertised to update-groups:
        1
  34 500
    14.14.14.4 from 14.14.14.4 (4.4.4.4)
      Origin IGP, localpref 100, valid, external
  34 500
    12.12.12.2 from 12.12.12.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, weight 100, valid, internal, best  ---- > already change the best path

R100(config-router)#do tracer 50.50.50.50 sour 10.10.10.10
Type escape sequence to abort.
Tracing the route to 50.50.50.50

  1 110.110.110.1 32 msec 8 msec 32 msec
  2 12.12.12.2 168 msec 44 msec 92 msec
  3 23.23.23.3 140 msec 120 msec 84 msec
  4 34.34.34.4 104 msec 92 msec 104 msec
  5 150.150.150.50 112 msec *  152 msec

Holysh##! You make my day BGP J