Weight attribute – BGP

Weight attribute – BGP
Below are the characteristics of weight:-

1.      
Manipulate Outgoing traffic
2.      
Cisco Proprietary
3.      
Only applicable when two exit points are on
single router.
4.      
Never advertise out from router and will remain
local to router.
5.      
Higher is preferred
6.      
Range is 0 – 65535.
7.      
When using Route-map to manipulate weight then
it cannot be applied in Outgoing direction as shown below. It has to be in inbound direction.
          
            R1(config-router)#neighbor 13.13.13.3 route-map SET_WEIGHT out
                % “SET_WEIGHT” used as BGP outbound route-map, set weight not supported


In below configuration example, R1 is having two paths to
reach to 20.1.1.x subnet and best path is from R2 i.e. 12.12.12.2. We want to
change the outgoing traffic from R1 to R3 by increasing the weight of R3 neighbor
but remember it will not manipulate the incoming traffic. It will change the
outgoing traffic directions only,



Weight will change the path for 20.1.1.x from R2 to R3.


R1:-

interface Loopback0
 ip address 1.1.1.1
255.255.255.255
interface FastEthernet0/0
 description ”
Connected to R2″
 ip address
12.12.12.1 255.255.255.0
no shut
interface FastEthernet0/1
 description ”
Connected to R3″
 ip address
13.13.13.1 255.255.255.0
 no shut
interface FastEthernet2/0
 description ”
Connected to PC1″
 ip address
10.1.1.1 255.255.255.0
no shut
router bgp 1
 no synchronization
 bgp
log-neighbor-changes
 network 10.1.1.0
mask 255.255.255.0
 neighbor 12.12.12.2
remote-as 1

 neighbor
13.13.13.3 remote-as 1

Without Weight configured.

R1#sh ip bgp
BGP table version is 3, 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, m multipath, b backup-path, x best-external
Origin codes: i – IGP, e – EGP, ? – incomplete
   Network          Next Hop            Metric LocPrf Weight Path
*> 10.1.1.0/24     
0.0.0.0                  0         32768 i
* i20.1.1.0/24     
13.13.13.3               0    100     
0 2 i

*>i                 12.12.12.2               0    100     
0 2 I
 \Route
Via R2 is preferred without weight


With Weight configured.

Weight can be set using any of the below methods:-

Option A:-

router bgp 1
neighbor 13.13.13.3 weight 100

OR

Option B:-  It is more flexible as in here we can apply
weight on specific routes as well by calling an Prefix-list or access-list that
matches the routes under Route map.

router bgp 1
neighbor 13.13.13.3 route-map SET_WEIGHT in

route-map 
SET_WEIGHT
set weight 100

R1#sh ip bgp
BGP table version is 4, 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, m multipath, b backup-path, x best-external
Origin codes: i – IGP, e – EGP, ? – incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 10.1.1.0/24     
0.0.0.0                  0         32768 i
*>i20.1.1.0/24      13.13.13.3               0   
100    100 2 I
  \Above configured weight has changed the path



* i                
12.12.12.2               0    100     
0 2 i
R2:-

interface Loopback0
 ip address 2.2.2.2
255.255.255.255

interface FastEthernet0/0
 description ”
Connected to R1″
 ip address
12.12.12.2 255.255.255.0
no shut

interface FastEthernet1/0
 description ”
Connected to R5″
 ip address
25.25.25.2 255.255.255.0
 no shut

router bgp 1
 no synchronization
 bgp router-id
2.2.2.2
 bgp
log-neighbor-changes
 neighbor
12.12.12.1 remote-as 1
 neighbor
12.12.12.1 next-hop-self
 neighbor
25.25.25.5 remote-as 2

R3:-

interface Loopback0
 ip address 3.3.3.3
255.255.255.255

interface FastEthernet0/1
description ” Connected to R1″
 ip address
13.13.13.3 255.255.255.0
no shut

interface FastEthernet1/0
description ” Connected to R4″
 ip address
34.34.34.3 255.255.255.0
no shut

router bgp 1
 no synchronization
 bgp router-id
3.3.3.3
 bgp
log-neighbor-changes
 neighbor
13.13.13.1 remote-as 1
 neighbor
13.13.13.1 next-hop-self
 neighbor
34.34.34.4 remote-as 2
 no auto-summary
!

R4:-

interface FastEthernet0/1
description ” Connected to R6″
 ip address
46.46.46.4 255.255.255.0
no shut

interface FastEthernet1/0
description ” Connected to R3″
 ip address
34.34.34.4 255.255.255.0
no shut

router bgp 2
 no synchronization
 bgp
log-neighbor-changes
 neighbor
34.34.34.3 remote-as 1
 neighbor
46.46.46.6 remote-as 2
 neighbor
46.46.46.6 next-hop-self
 no auto-summary
!
R5:-

interface Loopback0
 ip address 5.5.5.5
255.255.255.255

interface FastEthernet0/0
description ” Connected to R6″
 ip address
56.56.56.5 255.255.255.0
no shut

interface FastEthernet1/0
description ” Connected to R2″
 ip address
25.25.25.5 255.255.255.0
no shut

router bgp 2
 no synchronization
 bgp
log-neighbor-changes
 neighbor
25.25.25.2 remote-as 1
 neighbor
56.56.56.6 remote-as 2
 neighbor
56.56.56.6 next-hop-self
 no auto-summary


R6:-

interface Loopback0
 ip address 6.6.6.6
255.255.255.255

interface FastEthernet0/0
description ” Connected to R5″
 ip address
56.56.56.6 255.255.255.0
no shut

interface FastEthernet0/1
description ” Connected to R4″
 ip address
46.46.46.6 255.255.255.0
no shut

interface FastEthernet2/0
description ” Connected to PC2″
 ip address
20.1.1.1 255.255.255.0
 no shut

router bgp 2
 no synchronization
 bgp
log-neighbor-changes
 network 20.1.1.0
mask 255.255.255.0
 neighbor
46.46.46.4 remote-as 2
 neighbor
56.56.56.5 remote-as 2
 no auto-summary

PC1:-

PC1> show ip

NAME        :
PC1[1]
IP/MASK     :
10.1.1.10/24
GATEWAY     :
10.1.1.1
DNS         :
MAC         : 00:50:79:66:68:00
LPORT       : 10003
RHOST:PORT  :
127.0.0.1:10002
MTU:        : 1500

PC2:-
PC2> show ip

NAME        :
PC2[1]
IP/MASK     :
20.1.1.10/24
GATEWAY     :
20.1.1.1
DNS         :
MAC         :
00:50:79:66:68:00
LPORT       : 10003
RHOST:PORT  :
127.0.0.1:10002
MTU:        : 1500


Verification:-

R2:-

R2#sh ip bgp summ
BGP router identifier 2.2.2.2, local AS number 1
BGP table version is 3, main routing table version 3
2 network entries using 256 bytes of memory
2 path entries using 104 bytes of memory
2/2 BGP path/bestpath attribute entries using 248 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 632 total bytes of memory
BGP activity 2/0 prefixes, 2/0 paths, scan interval 60
secs

Neighbor       
V           AS MsgRcvd
MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
12.12.12.1     
4            1     316    
317        3    0   
0 04:41:15        1
25.25.25.5     
4            2     312    
313        3    0   
0 04:41:10        1

R2#sh ip bgp
BGP table version is 3, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid,
> best, i – internal,
              r
RIB-failure, S Stale, m multipath, b backup-path, x best-external
Origin codes: i – IGP, e – EGP, ? – incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i10.1.1.0/24     
12.12.12.1               0    100     
0 i
*> 20.1.1.0/24     
25.25.25.5                            
0 2 i


R3:-

R3#sh ip bgp summ
BGP router identifier 3.3.3.3, local AS number 1
BGP table version is 3, main routing table version 3
2 network entries using 256 bytes of memory
2 path entries using 104 bytes of memory
2/2 BGP path/bestpath attribute entries using 248 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 632 total bytes of memory
BGP activity 2/0 prefixes, 2/0 paths, scan interval 60
secs

Neighbor       
V           AS MsgRcvd
MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
13.13.13.1     
4            1     318    
314        3    0   
0 04:41:25        1
34.34.34.4     
4            2     312    
316        3    0   
0 04:41:21        1

R3#sh ip bgp
BGP table version is 3, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid,
> best, i – internal,
              r
RIB-failure, S Stale, m multipath, b backup-path, x best-external
Origin codes: i – IGP, e – EGP, ? – incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i10.1.1.0/24     
13.13.13.1               0    100     
0 i
*> 20.1.1.0/24     
34.34.34.4                            
0 2 i


R4:-

R4#sh ip bgp summ
BGP router identifier 4.4.4.4, local AS number 2
BGP table version is 4, main routing table version 4
2 network entries using 256 bytes of memory
2 path entries using 104 bytes of memory
2/2 BGP path/bestpath attribute entries using 248 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 632 total bytes of memory
BGP activity 2/0 prefixes, 2/0 paths, scan interval 60
secs

Neighbor       
V           AS MsgRcvd
MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
34.34.34.3     
4            1     323    
319        4    0   
0 04:47:19        1
46.46.46.6     
4            2     321    
320        4    0   
0 04:47:20        1

R4#sh ip bgp
BGP table version is 4, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid,
> best, i – internal,
              r
RIB-failure, S Stale, m multipath, b backup-path, x best-external
Origin codes: i – IGP, e – EGP, ? – incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 10.1.1.0/24     
34.34.34.3                            
0 1 i
*>i20.1.1.0/24     
46.46.46.6               0    100     
0 i
R4#

R5:-

R5#sh ip bgp summ
BGP router identifier 5.5.5.5, local AS number 2
BGP table version is 3, main routing table version 3
2 network entries using 256 bytes of memory
2 path entries using 104 bytes of memory
2/2 BGP path/bestpath attribute entries using 248 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 632 total bytes of memory
BGP activity 2/0 prefixes, 2/0 paths, scan interval 60
secs

Neighbor       
V           AS MsgRcvd MsgSent   TblVer 
InQ OutQ Up/Down  State/PfxRcd
25.25.25.2     
4            1     321    
320        3    0   
0 04:47:42        1
56.56.56.6     
4            2     319    
320        3    0   
0 04:47:43        1

R5#sh ip bgp
BGP table version is 3, 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, m multipath, b backup-path, x best-external
Origin codes: i – IGP, e – EGP, ? – incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 10.1.1.0/24     
25.25.25.2                            
0 1 i
*>i20.1.1.0/24     
56.56.56.6               0    100     
0 i
R5#
R6:-

R6#sh ip bgp summ
BGP router identifier 6.6.6.6, local AS number 2
BGP table version is 4, main routing table version 4
2 network entries using 256 bytes of memory
3 path entries using 156 bytes of memory
2/2 BGP path/bestpath attribute entries using 248 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 684 total bytes of memory
BGP activity 2/0 prefixes, 3/0 paths, scan interval 60
secs

Neighbor       
V           AS MsgRcvd
MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
46.46.46.4     
4            2     321    
322        4    0   
0 04:48:27        1
56.56.56.5     
4            2     320    
319        4    0   
0 04:48:28        1
R6#sh ip bgp
BGP table version is 4, local router ID is 6.6.6.6
Status codes: s suppressed, d damped, h history, * valid,
> best, i – internal,
              r
RIB-failure, S Stale, m multipath, b backup-path, x best-external
Origin codes: i – IGP, e – EGP, ? – incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i10.1.1.0/24     
46.46.46.4               0    100     
0 1 i
* i                
56.56.56.5               0    100     
0 1 i
*> 20.1.1.0/24     
0.0.0.0                  0         32768 i
R6#

PC1:-

PC1> trace 20.1.1.10
trace to 20.1.1.10, 8 hops max, press Ctrl+C to stop
 1   10.1.1.1  
40.000 ms  10.000 ms  10.000 ms
 2   13.13.13.3  
30.000 ms  30.000 ms  30.000 ms
 3   34.34.34.4  
50.000 ms  50.000 ms  50.000 ms
 4   46.46.46.6  
90.000 ms  80.000 ms  70.000 ms
 5   *20.1.1.10  
150.000 ms (ICMP type:3, code:3, Destination port unreachable)


PC2:-

PC2> trace 10.1.1.10
trace to 10.1.1.10, 8 hops max, press Ctrl+C to stop
 1   20.1.1.1  
10.000 ms  10.000 ms  10.000 ms
 2   46.46.46.4  
30.000 ms  30.000 ms  30.000 ms
 3   34.34.34.3  
40.000 ms  50.000 ms  50.000 ms
 4   13.13.13.1  
60.000 ms  60.000 ms  60.000 ms
 5   *10.1.1.10  
70.000 ms (ICMP type:3, code:3, Destination port unreachable)