Wednesday, 13 January 2021

BGP CHAPTER 18 - BGP ATTRIBUTE - MED

 MED - Multi Exit Discriminator - Metric


 

  •  MED can be used to manipulate the Incoming traffic entering into your AS.
  • The route with lower MED value is preferred.
  • The default value is 0
  • MED is exchanged between Autonomous Systems.
  • It is propagated to all the routers within the neighbor AS
  • But can't go beyond the neighbor AS - Hence it is Optional Non-Transitive. 
BGP MED

R1#sh int des | i up
Et2/0                          up             up       to R2
Et2/1                          up             up       to R3

R1#sh ip int brief | i up
Ethernet2/0            12.1.1.1        YES manual up                    up
Ethernet2/1            13.1.1.1        YES manual up                    up

R2#sh int des | i up
Et2/0                          up             up       to R1
Et2/1                          up             up       to R3
R2#
R2#sh ip int brief | i up
Ethernet2/0            12.1.1.2        YES manual up                    up
Ethernet2/1            23.1.1.2        YES manual up                    up
R2#

R3#sh int des | i up
Et2/0                          up             up       to R1
Et2/1                          up             up       to R2
R3#
R3#sh ip int brief | i up
Ethernet2/0            13.1.1.3        YES manual up                    up
Ethernet2/1            23.1.1.3        YES manual up                    up
R3#

! Lets configure an additional loopback on R1

R1(config)#int loopback 100
R1(config-if)#ip address 100.1.1.1 255.255.255.0
R1(config-if)#exit
R1(config)#exit
R1#
*Jan 13 08:01:29.523: %SYS-5-CONFIG_I: Configured from console by console

! BGP Configuration

R1#config t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#router bgp 100
R1(config-router)#neighbor 12.1.1.2 remote-as 100
R1(config-router)#neighbor 13.1.1.3 remote-as 200
R1(config-router)#network 100.1.1.0 mask 255.255.255.0
R1(config-router)#exit
R1(config)#exit
R1#wr

R2#config t
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#router bgp 100
R2(config-router)#neighbor 12.1.1.1 remote-as 100
R2(config-router)#
*Jan 13 08:05:02.079: %BGP-5-ADJCHANGE: neighbor 12.1.1.1 Up
R2(config-router)#neighbor 23.1.1.3 remote-as 200
R2(config-router)#exit
R2(config)#exit
R2#wr
Building configuration...
[OK]

R3#config t
Enter configuration commands, one per line.  End with CNTL/Z.
R3(config)#router bgp 200
R3(config-router)#neighbor 13.1.1.1 remote-as 100
R3(config-router)#
*Jan 13 08:06:21.163: %BGP-5-ADJCHANGE: neighbor 13.1.1.1 Up
R3(config-router)#neighbor 23.1.1.2 remote-as 100
R3(config-router)#
*Jan 13 08:06:37.443: %BGP-5-ADJCHANGE: neighbor 23.1.1.2 Up
R3(config-router)#exit
R3(config)#exit
R3#wr
Building configuration...

*Jan 13 08:06:43.707: %SYS-5-CONFIG_I: Configured from console by console[OK]

!!Verify the status of the BGP
R1#sh ip bgp summar
BGP router identifier 100.1.1.1, local AS number 100
BGP table version is 2, main routing table version 2
1 network entries using 144 bytes of memory
1 path entries using 80 bytes of memory
1/1 BGP path/bestpath attribute entries using 136 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
BGP using 360 total bytes of memory
BGP activity 1/0 prefixes, 1/0 paths, scan interval 60 secs

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
12.1.1.2        4          100       7       7        2    0    0 00:02:39        0
13.1.1.3        4          200       5       6        2    0    0 00:01:20        0

R2#sh ip bgp summary
BGP router identifier 23.1.1.2, local AS number 100
BGP table version is 2, main routing table version 2
1 network entries using 144 bytes of memory
1 path entries using 80 bytes of memory
1/1 BGP path/bestpath attribute entries using 136 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
BGP using 360 total bytes of memory
BGP activity 1/0 prefixes, 1/0 paths, scan interval 60 secs

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
12.1.1.1        4          100       8       7        2    0    0 00:02:59        1
23.1.1.3        4          200       8       6        2    0    0 00:01:24        0

R3#sh ip bgp summary
BGP router identifier 23.1.1.3, local AS number 200
BGP table version is 2, main routing table version 2
1 network entries using 144 bytes of memory
2 path entries using 160 bytes of memory
2/1 BGP path/bestpath attribute entries using 272 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
BGP using 600 total bytes of memory
BGP activity 1/0 prefixes, 2/0 paths, scan interval 60 secs

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
13.1.1.1        4          100       7       6        2    0    0 00:01:57        1
23.1.1.2        4          100       6       8        2    0    0 00:01:41        1

!!If you check on R3 for the network 100.1.1.0/24 the perferred path is through R1

R3#sh ip bgp
BGP table version is 2, local router ID is 23.1.1.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *   100.1.1.0/24     23.1.1.2                               0 100 i
 *>                   13.1.1.1                 0             0 100 i
R3#


R3#sh ip bgp 100.1.1.0
BGP routing table entry for 100.1.1.0/24, version 2
Paths: (2 available, best #2, table default)
  Advertised to update-groups:
     1
  Refresh Epoch 1
  100
    23.1.1.2 from 23.1.1.2 (23.1.1.2)
      Origin IGP, localpref 100, valid, external
      rx pathid: 0, tx pathid: 0
  Refresh Epoch 1
  100
    13.1.1.1 from 13.1.1.1 (100.1.1.1)
      Origin IGP, metric 0, localpref 100, valid, external, best
      rx pathid: 0, tx pathid: 0x0


Now using can change the incoming the traffic

Lets make few changes on R1

R1#config t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#route-map TEST
R1(config-route-map)#set metric ?
  +/-<metric>     Add or subtract metric
  <0-4294967295>  Metric value or Bandwidth in Kbits per second

R1(config-route-map)#set metric 100

R1(config)#router bgp 100
R1(config-router)#neighbor 13.1.1.3 route-map TEST out
R1(config-router)#exit
R1(config)#exit
R1#
R1#clear ip bgp * soft out

R3#sh ip bgp
BGP table version is 3, local router ID is 23.1.1.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>  100.1.1.0/24     23.1.1.2                               0 100 i
 *                    13.1.1.1               100             0 100 i


Thanks for Reading 

amartechstuff

No comments:

Post a Comment