How to configure Weight in BGP

In this session, we are going to see about how to configure Weight (BGP Attribute).
The Topology that we are going to see is shown below:
We have four different AS (AS1 , AS2, AS3 and AS4) as mentioned in the above topology.
Our AS 4 have two Loopback interfaces (Loopback 0 and Loopback 1)
Our aim to reach the loopback 0 (4.4.4.4/32) via AS 3 and loopback 1 (44.44.44.44/32) via AS 2 by using Weight (BGP Attribute).
R1 interface Configuration:
R1#show ip int brief 
    Interface IP-Address OK? Method Status Protocol
    FastEthernet0/0 192.168.12.1 YES NVRAM up up
    FastEthernet0/1 192.168.13.1 YES NVRAM up up
R1#show running-config interface fastEthernet 0/0
Building configuration...
Current configuration : 97 bytes
!
interface FastEthernet0/0
ip address 192.168.12.1 255.255.255.0
duplex auto
speed auto
end

R1#show running-config interface fastEthernet 0/1
Building configuration...
Current configuration : 97 bytes
!
interface FastEthernet0/1
ip address 192.168.13.1 255.255.255.0
duplex auto
speed auto
end
R2 interface Configuration:
R2#show ip int brief 
    Interface IP-Address OK? Method Status Protocol
    FastEthernet0/0 192.168.12.2 YES NVRAM up up   
    FastEthernet0/1 192.168.24.2 YES NVRAM up up
R2#show running-config interface fastEthernet 0/0
Building configuration...
Current configuration : 97 bytes
!
interface FastEthernet0/0
ip address 192.168.12.2 255.255.255.0
duplex auto
speed auto
end

R2#show running-config interface fastEthernet 0/1
Building configuration...
Current configuration : 97 bytes
!
interface FastEthernet0/1
ip address 192.168.24.2 255.255.255.0
duplex auto
speed auto
end
R3 interface Configuration:
R3#show ip int brief 
    Interface IP-Address OK? Method Status Protocol
    FastEthernet0/0 192.168.13.3 YES NVRAM up up
    FastEthernet0/1 192.168.34.3 YES NVRAM up up
R3#show running-config interface fastEthernet 0/0
Building configuration...
Current configuration : 97 bytes
!
interface FastEthernet0/0
ip address 192.168.13.3 255.255.255.0
duplex auto
speed auto
end

R3#
R3#show running-config interface fastEthernet 0/1
Building configuration...
Current configuration : 97 bytes
!
interface FastEthernet0/1
ip address 192.168.34.3 255.255.255.0
duplex auto
speed auto
end
R4 interface Configuration:
R4#show ip interface brief 
    Interface IP-Address OK? Method Status Protocol
    FastEthernet0/0 192.168.24.4 YES NVRAM up up
    FastEthernet0/1 192.168.34.4 YES NVRAM up up
    Loopback0 4.4.4.4 YES NVRAM up up
    Loopback1 44.44.44.44 YES NVRAM up up
R4#show running-config interface fastEthernet 0/0
Building configuration...
Current configuration : 97 bytes
!
interface FastEthernet0/0
ip address 192.168.24.4 255.255.255.0
duplex auto
speed auto
end

R4#show running-config interface fastEthernet 0/1
Building configuration...
Current configuration : 97 bytes
!
interface FastEthernet0/1
ip address 192.168.34.4 255.255.255.0
duplex auto
speed auto
end

R4#show running-config interface loo
R4#show running-config interface loopback 0
Building configuration...
Current configuration : 63 bytes
!
interface Loopback0
ip address 4.4.4.4 255.255.255.255
end

R4#show running-config interface loopback 1
Building configuration...
Current configuration : 67 bytes
!
interface Loopback1
ip address 44.44.44.44 255.255.255.255
end
R1 BGP Configuration :
R1#show running-config | section router bgp
router bgp 1
redistribute connected
neighbor 192.168.12.2 remote-as 2
neighbor 192.168.13.3 remote-as 3
R2 BGP Configuration :
R2#show running-config | section router bgp
router bgp 2
redistribute connected
neighbor 192.168.12.1 remote-as 1
neighbor 192.168.24.4 remote-as 4
R3 BGP Configuration :
R3#show running-config | section router bgp
router bgp 3
redistribute connected
neighbor 192.168.13.1 remote-as 1
neighbor 192.168.34.4 remote-as 4
R4 BGP Configuration :
R4#show running-config | section router bgp
router bgp 4
redistribute connected
neighbor 192.168.24.2 remote-as 2
neighbor 192.168.34.3 remote-as 3
If you look at the above configuration, I have formed BGP neighborship with the Physical interfaces. You can also see i have used a command  "redistribute connected" .
This command helps you to redistribute and advertise the networks in the router in BGP. I have done this for reachability purpose.
BGP Neighborship verification on R1:
R1#show ip bgp summary | begin Neighbor
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
192.168.12.2 4 2 87 91 9 0 0 00:07:19 5
192.168.13.3 4 3 86 91 9 0 0 00:06:37 1
BGP Neighborship verification on R2:
R2#show ip bgp summary | begin Neighbor
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
192.168.12.1 4 1 91 87 10 0 0 00:07:27 3
192.168.24.4 4 4 83 84 10 0 0 00:06:32 5
BGP Neighborship verification on R3:
R3#show ip bgp summary | begin Neighbor
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
192.168.13.1 4 1 91 86 10 0 0 00:06:47 5
192.168.34.4 4 4 83 83 10 0 0 00:06:15 5
BGP Neighborship verification on R4:
R4#show ip bgp summary | begin Neighbor
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
192.168.24.2 4 2 84 83 13 0 0 00:06:36 3
192.168.34.3 4 3 83 83 13 0 0 00:06:16 3
Now we will check the which path BGP will chose to reach the 4.4.4.4/32 and 44.44.44.44/32 on Router r1:
R1#show ip bgp 4.4.4.4/32 
BGP routing table entry for 4.4.4.4/32, version 2
Paths: (2 available, best #2, table Default-IP-Routing-Table)
Flag: 0x820
Advertised to update-groups:
1
3 4
192.168.13.3 from 192.168.13.3 (192.168.34.3)
Origin incomplete, localpref 100, valid, external
2 4
192.168.12.2 from 192.168.12.2 (192.168.24.2)
Origin incomplete, localpref 100, valid, external, best
R1#show ip bgp 44.44.44.44/32
BGP routing table entry for 44.44.44.44/32, version 3
Paths: (2 available, best #2, table Default-IP-Routing-Table)
Flag: 0x820
Advertised to update-groups:
1
3 4
192.168.13.3 from 192.168.13.3 (192.168.34.3)
Origin incomplete, localpref 100, valid, external
2 4
192.168.12.2 from 192.168.12.2 (192.168.24.2)
Origin incomplete, localpref 100, valid, external, best
  From the above output we come to know that, both the networks are reachable via Next-hop -192.168.12.2 as it is the best-path.
The Highlighted things in blue are the AS numbers that it crosses to reach that Network.
Now our goal is to reach the loopback 0 (4.4.4.4/32) via AS 3 and loopback 1 (44.44.44.44/32) via AS 2 by using Weight (BGP Attribute). For this we are now going to create the route-map.
Route-map Configuration :
R1(config)#route-map WEIGHT permit 10
R1(config-route-map)#match ip address 1
R1(config-route-map)#set weight 1500
R1(config-route-map)#exit
R1(config)#
Now we have created route-map with the name WEIGHT, we have match it with the access-list 1 (Match ip address is nothing but matching the Access-list), and if it matches that Access-list 1 , it will set the weight to 1500.
Access-list configuration:
R1(config)#access-list 1 permit 4.4.4.4 0.0.0.0
We have crested the access-list 1, for the prefix 4.4.4.4 /32. If the particular prefix matches, it will set the weight to 1500 for that prefix.
BGP Configuration to apply route-map to neighbor:
R1#configure terminal 
R1(config)#router bgp 1
R1(config-router)#neighbor 192.168.13.3 route-map WEIGHT in
R1(config-router)#exit
R1(config)#
We have now applied route-map to the neighbor 192.168.13.3 inbound. Make sure that Route-map names are Case-sensitive.
R1#clear ip bgp * soft
Just clear the BGP sessions by using the above command. Don't forget to use the soft command, or else it will the BGP TCP sessions and BGP will be re-established.
You can now see the below output after clearing the BGP Sessions:
R1#show ip bgp 4.4.4.4/32
BGP routing table entry for 4.4.4.4/32, version 10
Paths: (2 available, best #1, table Default-IP-Routing-Table)
Flag: 0x820
Advertised to update-groups:
1
3 4
192.168.13.3 from 192.168.13.3 (192.168.34.3)
Origin incomplete, localpref 100, weight 1500, valid, external, best
2 4
192.168.12.2 from 192.168.12.2 (192.168.24.2)
Origin incomplete, localpref 100, valid, external
R1#show ip bgp 44.44.44.44/32
BGP routing table entry for 44.44.44.44/32, version 3
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Advertised to update-groups:
1
2 4
192.168.12.2 from 192.168.12.2 (192.168.24.2)
Origin incomplete, localpref 100, valid, external, best
Now you can see the for the prefix 4.4.4.4/32 the traffic moves via 192.168.13.2 with the weight value of 1500.
You can also look in to my Video tutorial:

That's it about Weight in BGP Configuration.

Post a Comment