Tuesday, 4 December 2018

BGP Multi Exit Discriminator (MED)



Multi Exit Discriminator (MED) also called metric. MED is an optional and nontransitive attribute; MED allows an autonomous system to tell a neighboring autonomous system the best way to forward packets into the first autonomous system. MED is used to advertise one autonomous system into another, propagated inside the autonomous system, but not sent to any other autonomous systems. A smaller MED value means more preferred, by default 0 and the range is 0 through 4,294,967,295. MED originally worked for a dual-homed design.
MED is used in the route selection process only if all the paths come from the same Autonomous System. BGP uses the BGP always-compare-med command to force the router to compare the MED even if the paths come from different autonomous systems. If you are enabling this option then enable it entire autonomous system otherwise loops can be occurring.  






 Let see the configuration :

Topology:


Goal:
  • configure the topology as per the diagram.
  • configure iBGP and EBGP and advertise the interface as per the topology
  • configure the autonomous system (65222) to exit via router 1 - router 4 (AS 65444).
  • configure autonomous system 65111 return traffic from 65222 also should use the same path ( R2-R3-R4) as exit.
  • use MED 



R1#show ip interface brief


Interface              IP-Address      OK? Method Status                Protocol

FastEthernet0/0        10.1.1.1        YES manual up                    up


Serial3/0                   1.1.1.1         YES manual up                    up
Serial3/3                   4.1.1.2         YES manual up                    up
Loopback0              11.0.0.1        YES manual up                    up
Loopback1              11.0.1.1        YES manual up                    up
Loopback2              11.0.2.1        YES manual up                    up
Loopback3              11.0.3.1        YES manual up                    up



 R2#show ip interface brief

Interface              IP-Address      OK? Method Status                Protocol
Serial3/0              1.1.1.2         YES manual up                    up
Serial3/1              2.1.1.1         YES manual up                    up
Loopback0              12.0.0.1        YES manual up                    up
Loopback1              12.0.1.1        YES manual up                    up
Loopback2              12.0.3.1        YES manual up                    up


R3#show ip interface brief
Interface              IP-Address      OK? Method Status                Protocol
FastEthernet0/0        30.1.1.1        YES manual up                    up
Serial3/1              2.1.1.2         YES manual up                    up
Serial3/2              3.1.1.1         YES manual up                    up
Loopback0              13.0.0.1        YES manual up                    up
Loopback1              13.0.1.1        YES manual up                    up
Loopback2              13.0.2.1        YES manual up                    up
Loopback3              13.0.3.1        YES manual up                    up

R4#show ip interface brief
Interface              IP-Address      OK? Method Status                Protocol
FastEthernet0/0        40.1.1.1        YES manual up                    up
Serial3/2              3.1.1.2         YES manual up                    up
Serial3/3              4.1.1.1         YES manual up                    up
Loopback0              14.0.0.1        YES manual up                    up
Loopback1              14.0.1.1        YES manual up                    up
Loopback2              14.0.2.1        YES manual up                    up
Loopback3              14.0.3.1        YES manual up                    up



R1(config)#router bgp 65111
R1(config-router)#neighbor 1.1.1.2 remote-as 65222
R1(config-router)#neighbor 4.1.1.1 remote-as 65444
R1(config-router)#network 1.0.0.0
R1(config-router)#network 4.0.0.0
R1(config-router)#network 10.0.0.0
R1(config-router)#network 11.0.0.0 mask  255.255.255.0
R1(config-router)#no synchronization
R1(config-router)#no auto-summary


R2(config)#router bgp 65222
R2(config-router)#neighbor 1.1.1.1 remote-as 65111
R2(config-router)#neighbor 2.1.1.2 remote-as 65222
R2(config-router)#neighbor 2.1.1.2 next-hop-self
R2(config-router)#network 1.0.0.0
R2(config-router)#network 2.0.0.0
R2(config-router)#network 20.0.0.0
R2(config-router)#network 12.0.0.0 mask 255.255.255.0
R2(config-router)#no auto-summary
R2(config-router)#no synchronization


R3(config)#router bgp 65222
R3(config-router)#neighbor 2.1.1.1 remote-as 65222
R3(config-router)#neighbor 2.1.1.1 next-hop-self
R3(config-router)#neighbor 3.1.1.2 remote-as 65333
R3(config-router)#network 30.0.0.0
R3(config-router)#network 3.0.0.0
R3(config-router)#network 2.0.0.0
R3(config-router)#network 13.0.0.0 mask 255.255.255.0
R3(config-router)#no auto-summary
R3(config-router)#no synchronization


R4(config)#router bgp 65444
R4(config-router)#neighbor 3.1.1.1 remote-as 65222
R4(config-router)#neighbor 4.1.1.2 remote-as 65111
R4(config-router)#network 40.0.0.0
R4(config-router)#network 4.0.0.0
R4(config-router)#network 14.0.0.0 mask 255.255.255.0
R4(config-router)#network 3.0.0.0
R4(config-router)#no auto-summary
R4(config-router)#no synchronization


R1#show ip bgp summary
BGP router identifier 11.0.3.1, local AS number 65111
BGP table version is 19, main routing table version 19
12 network entries using 1728 bytes of memory
23 path entries using 1840 bytes of memory
6/4 BGP path/bestpath attribute entries using 816 bytes of memory
4 BGP AS-PATH entries using 96 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 4480 total bytes of memory
BGP activity 15/3 prefixes, 26/3 paths, scan interval 60 secs

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
1.1.1.2         4        65222      21      18       19    0    0 00:12:09        9
4.1.1.1         4        65444      12      12       19    0    0 00:02:22       10


R2#show ip bgp
BGP table version is 22, local router ID is 12.0.3.1
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
 *>  1.0.0.0          0.0.0.0                  0         32768 i
 *                    1.1.1.1                  0             0 65111 i
 * i 2.0.0.0          2.1.1.2                  0    100      0 i
 *>                   0.0.0.0                  0         32768 i
 *   3.0.0.0          1.1.1.1                                0 65111 65444 i
 *>i                  2.1.1.2                  0    100      0 i
 * i 4.0.0.0          3.1.1.2                  0    100      0 65444 i
 *>                   1.1.1.1                  0             0 65111 i
 *>  10.0.0.0         1.1.1.1                  0             0 65111 i
 *>  11.0.0.0/24      1.1.1.1                  0             0 65111 i
 *>  12.0.0.0/24      0.0.0.0                  0         32768 i
 *>i 13.0.0.0/24      2.1.1.2                  0    100      0 i
 *>i 14.0.0.0/24      3.1.1.2                  0    100      0 65444 i
 *                    1.1.1.1                                0 65111 65444 i
     Network          Next Hop            Metric LocPrf Weight Path
 *>  20.0.0.0         0.0.0.0                  0         32768 i
 *>i 30.0.0.0         2.1.1.2                  0    100      0 i
 *>i 40.0.0.0         3.1.1.2                  0    100      0 65444 i
 *                    1.1.1.1                                0 65111 65444 i
R2#show ip bgp summary
BGP router identifier 12.0.3.1, local AS number 65222
BGP table version is 22, main routing table version 22
12 network entries using 1728 bytes of memory
18 path entries using 1440 bytes of memory
5/4 BGP path/bestpath attribute entries using 680 bytes of memory
3 BGP AS-PATH entries using 72 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 3920 total bytes of memory
BGP activity 15/3 prefixes, 22/4 paths, scan interval 60 secs


Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
1.1.1.1         4        65111      48      45       22    0    0 00:25:50        7
2.1.1.2         4        65222      27      28       22    0    0 00:18:59        7

R3#show ip bgp summary
BGP router identifier 13.0.3.1, local AS number 65222
BGP table version is 15, main routing table version 15
12 network entries using 1728 bytes of memory
17 path entries using 1360 bytes of memory
5/4 BGP path/bestpath attribute entries using 680 bytes of memory
3 BGP AS-PATH entries using 72 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 3840 total bytes of memory
BGP activity 12/0 prefixes, 19/2 paths, scan interval 60 secs


Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
2.1.1.1         4        65222      28      28       15    0    0 00:19:29        7
3.1.1.2         4        65444      25      27       15    0    0 00:17:55        6

R4#show ip bgp summary
BGP router identifier 14.0.3.1, local AS number 65444
BGP table version is 18, main routing table version 18
12 network entries using 1728 bytes of memory
22 path entries using 1760 bytes of memory
6/4 BGP path/bestpath attribute entries using 816 bytes of memory
4 BGP AS-PATH entries using 96 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 4400 total bytes of memory
BGP activity 12/0 prefixes, 29/7 paths, scan interval 60 secs

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
3.1.1.1         4        65222      28      25       18    0    0 00:18:27        9
4.1.1.2         4        65111      43      41       18    0    0 00:17:04        9


R1#show ip bgp
BGP table version is 19, local router ID is 11.0.3.1
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
 *   1.0.0.0          4.1.1.1                                0 65444 65222 i
 *                    1.1.1.2                  0             0 65222 i
 *>                   0.0.0.0                  0         32768 i
 *   2.0.0.0          4.1.1.1                                0 65444 65222 i
 *>                   1.1.1.2                  0             0 65222 i
 *   3.0.0.0          4.1.1.1                  0             0 65444 i
 *>                   1.1.1.2                                0 65222 i
 *   4.0.0.0          4.1.1.1                  0             0 65444 i
 *>                   0.0.0.0                  0         32768 i
 *>  10.0.0.0         0.0.0.0                  0         32768 i
 *>  11.0.0.0/24      0.0.0.0                  0         32768 i
 *   12.0.0.0/24      4.1.1.1                                0 65444 65222 i
 *>                   1.1.1.2                  0             0 65222 i
 *   13.0.0.0/24      4.1.1.1                                0 65444 65222 i
     Network          Next Hop            Metric LocPrf Weight Path
 *>                   1.1.1.2                                0 65222 i
 *   14.0.0.0/24      1.1.1.2                                0 65222 65444 i
 *>                   4.1.1.1                  0             0 65444 i
 *   20.0.0.0         4.1.1.1                                0 65444 65222 i
 *>                   1.1.1.2                  0             0 65222 i
 *   30.0.0.0         4.1.1.1                                0 65444 65222 i
 *>                   1.1.1.2                                0 65222 i
 *   40.0.0.0         1.1.1.2                                0 65222 65444 i
 *>                   4.1.1.1                  0             0 65444 i


R1#show ip bgp 20.0.0.0
BGP routing table entry for 20.0.0.0/8, version 29
Paths: (2 available, best #2, table default)
  Advertised to update-groups:
     1
  Refresh Epoch 4
  65444 65222
    4.1.1.1 from 4.1.1.1 (14.0.3.1)
      Origin IGP, localpref 100, valid, external
      rx pathid: 0, tx pathid: 0
  Refresh Epoch 3
  65222
    1.1.1.2 from 1.1.1.2 (12.0.3.1)
      Origin IGP, metric 0, localpref 100, valid, external, best
      rx pathid: 0, tx pathid: 0x0


R1#show ip bgp 30.0.0.0
BGP routing table entry for 30.0.0.0/8, version 32
Paths: (2 available, best #2, table default)
  Advertised to update-groups:
     1
  Refresh Epoch 4
  65444 65222
    4.1.1.1 from 4.1.1.1 (14.0.3.1)
      Origin IGP, localpref 100, valid, external
      rx pathid: 0, tx pathid: 0
  Refresh Epoch 3
  65222
    1.1.1.2 from 1.1.1.2 (12.0.3.1)
      Origin IGP, localpref 100, valid, external, best
      rx pathid: 0, tx pathid: 0x0


R1#traceroute 20.1.1.1
Type escape sequence to abort.
Tracing the route to 20.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
  1 1.1.1.2 76 msec 36 msec 16 msec

R1#traceroute 30.1.1.1
Type escape sequence to abort.
Tracing the route to 30.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
  1 1.1.1.2 4 msec 80 msec 44 msec
  2 2.1.1.2 [AS 65222] 80 msec 112 msec 104 msec



R1(config)#router bgp 65111

R1(config-router)#neighbor 4.1.1.1 weight 10000

R1(config-router)#do clear ip bgp * soft


R1#show ip bgp
BGP table version is 43, local router ID is 11.0.3.1
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
 *   1.0.0.0          4.1.1.1                            10000 65444 65222 i
 *                    1.1.1.2                  0             0 65222 i
 *>                   0.0.0.0                  0         32768 i
 *>  2.0.0.0          4.1.1.1                            10000 65444 65222 i
 *                    1.1.1.2                  0             0 65222 i
 *>  3.0.0.0          4.1.1.1                  0         10000 65444 i
 *                    1.1.1.2                                0 65222 i
 *   4.0.0.0          4.1.1.1                  0         10000 65444 i
 *>                   0.0.0.0                  0         32768 i
 *>  10.0.0.0         0.0.0.0                  0         32768 i
 *>  11.0.0.0/24      0.0.0.0                  0         32768 i
 *>  12.0.0.0/24      4.1.1.1                            10000 65444 65222 i
 *                    1.1.1.2                  0             0 65222 i
 *>  13.0.0.0/24      4.1.1.1                            10000 65444 65222 i
     Network          Next Hop            Metric LocPrf Weight Path
 *                    1.1.1.2                                0 65222 i
 *   14.0.0.0/24      1.1.1.2                                0 65222 65444 i
 *>                   4.1.1.1                  0         10000 65444 i
 *>  20.0.0.0         4.1.1.1                            10000 65444 65222 i
 *                    1.1.1.2                  0             0 65222 i
 *>  30.0.0.0         4.1.1.1                            10000 65444 65222 i
 *                    1.1.1.2                                0 65222 i
 *   40.0.0.0         1.1.1.2                                0 65222 65444 i
 *>                   4.1.1.1                  0         10000 65444 i
R1#show ip bgp 20.0.0.0
BGP routing table entry for 20.0.0.0/8, version 37
Paths: (2 available, best #1, table default)
  Advertised to update-groups:
     1
  Refresh Epoch 5
  65444 65222
    4.1.1.1 from 4.1.1.1 (14.0.3.1)
      Origin IGP, localpref 100, weight 10000, valid, external, best
      rx pathid: 0, tx pathid: 0x0
  Refresh Epoch 4
  65222
    1.1.1.2 from 1.1.1.2 (12.0.3.1)
      Origin IGP, metric 0, localpref 100, valid, external
      rx pathid: 0, tx pathid: 0
R1#show ip bgp 30.0.0.0
BGP routing table entry for 30.0.0.0/8, version 40
Paths: (2 available, best #1, table default)
  Advertised to update-groups:
     1
  Refresh Epoch 5
  65444 65222
    4.1.1.1 from 4.1.1.1 (14.0.3.1)
      Origin IGP, localpref 100, weight 10000, valid, external, best
      rx pathid: 0, tx pathid: 0x0
  Refresh Epoch 4
  65222
    1.1.1.2 from 1.1.1.2 (12.0.3.1)
      Origin IGP, localpref 100, valid, external
      rx pathid: 0, tx pathid: 0


R1#show ip bgp 30.0.0.0/8 longer-prefixes
BGP table version is 43, local router ID is 11.0.3.1
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
 *>  30.0.0.0         4.1.1.1                            10000 65444 65222 i
 *                    1.1.1.2                                0 65222 i

R1#show ip bgp 20.0.0.0/8 longer-prefixes
BGP table version is 43, local router ID is 11.0.3.1
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
 *>  20.0.0.0         4.1.1.1                            10000 65444 65222 i
 *                    1.1.1.2                  0             0 65222 i



R1#traceroute 20.1.1.1
Type escape sequence to abort.
Tracing the route to 20.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
  1 4.1.1.1 180 msec 96 msec 80 msec
  2 3.1.1.1 [AS 65444] 92 msec 220 msec 188 msec
  3 2.1.1.1 [AS 65222] 304 msec 160 msec 132 msec

R1#traceroute 30.1.1.1
Type escape sequence to abort.
Tracing the route to 30.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
  1 4.1.1.1 44 msec 64 msec 104 msec
  2 3.1.1.1 [AS 65444] 192 msec 152 msec 88 msec


R1(config)#route-map internet permit 10
R1(config-route-map)#set metric 120
R1(config-route-map)#set as-path prepend 65111
R1(config-route-map)#exit


R1(config)#router bgp 65111
R1(config-router)#neighbor 1.1.1.2 route-map internet out
R1(config-router)#end

R1#clear ip bgp * soft

R2#show ip bgp
BGP table version is 25, local router ID is 12.0.3.1
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
 *>  1.0.0.0          0.0.0.0                  0         32768 i
 *                    1.1.1.1                120             0 65111 65111 i
 * i 2.0.0.0          2.1.1.2                  0    100      0 i
 *>                   0.0.0.0                  0         32768 i
 *   3.0.0.0          1.1.1.1                120             0 65111 65111 65444 i
 *>i                  2.1.1.2                  0    100      0 i
 *>i 4.0.0.0          3.1.1.2                  0    100      0 65444 i
 *                    1.1.1.1                120             0 65111 65111 i
 * i 10.0.0.0         3.1.1.2                  0    100      0 65444 65111 i
 *>                   1.1.1.1                120             0 65111 65111 i
 * i 11.0.0.0/24      3.1.1.2                  0    100      0 65444 65111 i
 *>                   1.1.1.1                120             0 65111 65111 i
 *>  12.0.0.0/24      0.0.0.0                  0         32768 i
 *>i 13.0.0.0/24      2.1.1.2                  0    100      0 i
     Network          Next Hop            Metric LocPrf Weight Path
 *>i 14.0.0.0/24      3.1.1.2                  0    100      0 65444 i
 *                    1.1.1.1                120             0 65111 65111 65444 i
 *>  20.0.0.0         0.0.0.0                  0         32768 i
 *>i 30.0.0.0         2.1.1.2                  0    100      0 i
 *>i 40.0.0.0         3.1.1.2                  0    100      0 65444 i
 *                    1.1.1.1                120             0 65111 65111 65444 i


R2#show ip bgp 10.0.0.0
BGP routing table entry for 10.0.0.0/8, version 24
Paths: (2 available, best #2, table default)
  Advertised to update-groups:
     3
  Refresh Epoch 1
  65444 65111
    3.1.1.2 from 2.1.1.2 (13.0.3.1)
      Origin IGP, metric 0, localpref 100, valid, internal
      rx pathid: 0, tx pathid: 0
  Refresh Epoch 4
  65111 65111
    1.1.1.1 from 1.1.1.1 (11.0.3.1)
      Origin IGP, metric 120, localpref 100, valid, external, best
      rx pathid: 0, tx pathid: 0x0


R2#show ip bgp 10.0.0.0/8 longer-prefixes
BGP table version is 25, local router ID is 12.0.3.1
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
 * i 10.0.0.0         3.1.1.2                  0    100      0 65444 65111 i
 *>                   1.1.1.1                120             0 65111 65111 i



R2(config)# router bgp 65222

R2(config-router)#bgp always-compare-med


R3(config)#router bgp 65222
R3(config-router)#bgp always-compare-med

R2#show ip bgp 10.0.0.0
BGP routing table entry for 10.0.0.0/8, version 30
Paths: (2 available, best #1, table default)
  Advertised to update-groups:
     1
  Refresh Epoch 1
  65444 65111
    3.1.1.2 from 2.1.1.2 (13.0.3.1)
      Origin IGP, metric 0, localpref 100, valid, internal, best
      rx pathid: 0, tx pathid: 0x0
  Refresh Epoch 4
  65111 65111
    1.1.1.1 from 1.1.1.1 (11.0.3.1)
      Origin IGP, metric 120, localpref 100, valid, external
      rx pathid: 0, tx pathid: 0


R2#traceroute 10.1.1.1
Type escape sequence to abort.
Tracing the route to 10.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
  1 2.1.1.2 88 msec 68 msec 32 msec
  2 3.1.1.2 100 msec 64 msec 92 msec
  3 4.1.1.2 [AS 65444] 160 msec 108 msec 100 msec

R3#traceroute 10.1.1.1
Type escape sequence to abort.
Tracing the route to 10.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
  1 3.1.1.2 92 msec 44 msec 32 msec
  2 4.1.1.2 [AS 65444] 88 msec 56 msec 56 msec


R4#traceroute 10.1.1.1
Type escape sequence to abort.
Tracing the route to 10.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
  1 4.1.1.2 24 msec 36 msec 32 msec



 


 


Instagram

Facebook


Twitter



LINKEDIN








No comments:

What is Switch Port Analyzer SPAN, RSPAN? How to configure SPAN and RSPAN?

   What are SPAN and RSPAN? Cisco Catalyst Switches have a feature called SPAN (Switch Port Analyzer). This feature is used for directing ...