What weight is
Weight is a number from 0 to 65535 that a Cisco router attaches to every path in its own BGP table. It is never placed in a BGP UPDATE, so it exists only on the router where you set it. The path with the highest weight is the best path, and the comparison is made before any other attribute.
Paths the router originated with the network command, redistribution or aggregation start at 32768. Paths learned from a neighbour start at 0. That is why a locally originated route beats a learned route to the same prefix without any configuration.
On small screens, swipe sideways or focus the diagram and use the arrow keys.
Where weight sits in the decision
Cisco IOS XE walks a fixed list of comparisons and stops at the first one that finds a difference. Weight is step 1, so if two paths have different weights nothing else is looked at, not local preference, not AS path length.
On small screens, swipe sideways or focus the diagram and use the arrow keys.
Setting weight
There are two ways. The neighbour command sets one value for every route from that neighbour. A route map lets you match some routes and give them a different weight.
router bgp 64500
address-family ipv4 unicast
neighbor 192.0.2.1 weight 300
end
clear ip bgp 192.0.2.1 soft inR1. Every route learned from ISP A at 192.0.2.1 gets weight 300. Routes from ISP B stay at 0, so R1 prefers ISP A for every prefix both can reach.
ip prefix-list WEB-NETS seq 5 permit 203.0.113.0/24
!
route-map ISPA-WEIGHT permit 10
match ip address prefix-list WEB-NETS
set weight 300
route-map ISPA-WEIGHT permit 20
!
router bgp 64500
address-family ipv4 unicast
neighbor 192.0.2.1 route-map ISPA-WEIGHT in
end
clear ip bgp 192.0.2.1 soft inR1. Only 203.0.113.0/24 learned from ISP A gets weight 300. Sequence 20 permits everything else unchanged, so the rest of ISP A's routes are not dropped by the implicit deny.
The soft clear matters. Weight is applied when a route is received, so the new value only takes effect on routes that are processed again. A soft inbound clear asks the neighbour to resend, or replays stored copies, without closing the session.
How weight steers traffic
Weight changes where this router sends its outbound traffic, and nothing else. Traffic that enters the AS at another router follows that router's own choice. It has no effect on how the internet reaches you.
On small screens, swipe sideways or focus the diagram and use the arrow keys.
That makes weight right for a narrow job: a remote-site router that must always use its local ISP, a lab test, or a temporary exception while you fix the real policy. For an exit choice the whole AS should follow, use local preference instead.
Reading weight in show output
R1#show ip bgp 203.0.113.0 BGP routing table entry for 203.0.113.0/24, version 14 Paths: (2 available, best #1, table default) 64501 192.0.2.1 from 192.0.2.1 (11.11.11.11) Origin IGP, metric 0, localpref 100, weight 300, valid, external, best 64502 192.0.2.5 from 192.0.2.5 (12.12.12.12) Origin IGP, metric 0, localpref 100, valid, external
In the table form, show ip bgp prints a Weight column on the right. A value of 32768 marks a route this router originated.
Worked example: a stuck backup path after redistribution
A classic weight problem appears when a site learns the same prefix from two sources. R1 learns 198.51.100.0/24 over eBGP from the provider and, at the same time, an IGP route to it is redistributed into BGP on R2 inside the AS. A redistributed route is locally originated on R2, so it carries weight 32768 there. On R2 that path beats the iBGP-learned path from R1 at step 1, before local preference is ever looked at, so R2 keeps sending traffic out through the backup exit even though the primary exit is healthy.
The fix is not to raise local preference, because weight is compared first. Lower the weight of the redistributed path on R2 with a route map, so that the learned path wins and the redistributed one stays as a backup.
route-map REDIST-WEIGHT permit 10
set weight 0
!
router bgp 64500
address-family ipv4 unicast
redistribute eigrp 100 route-map REDIST-WEIGHT
end
clear ip bgp * soft outR2. Redistributed routes now enter the BGP table with weight 0 instead of 32768. The iBGP path from R1 can win on local preference, and the redistributed path is used only if that path disappears. Use a value such as 40000 instead when the redistributed path must win.
Both directions are valid. Which value you choose depends on whether the redistributed route is the primary or the backup path. The point of the example is that a locally originated path is not neutral: it starts with the highest default weight and wins unless you change it.
Mistakes to avoid
On small screens, swipe sideways or focus the diagram and use the arrow keys.
Check your understanding
R1 has weight 300 on ISP A routes and R2 has no weight configured. Where does traffic leave the AS?
Which paths start with weight 32768?
Weight and local preference differ. Which statement is correct?