In general, they help determine paths within a network. A BGP attribute can also be used to determine the best route for a prefix when multiple paths are available.
What are the types of BGP attributes?
There are four in total, each with its own functionality. Let's take a look at them:
1- Well known mandatory attributes: mandatory attributes, must be known on all equipment using BGP, and must be included in all update messages.
For example: Local_Pref – Local Preference
3- Optional transitive attributes: Transitive attributes that can be recognized by devices that "speak" BGP, but not necessarily by all. They are forwarded to neighboring routers, whether they are recognized or not.
For example: Community – Community string
4- Optional non-transitive attributes: Non-transitive attributes can be recognized by devices that "speak" BGP, but not by all. They are not forwarded to neighboring routers, maintaining their applicability within their local network.
For example: MED – Multi-Exit Discriminator
BGP attribute priority order
- Weight: the higher the value, the better the route.
- Local_Pref: the higher the value, the better the route.
- Originate: prefers locally generated routes.
- AS_Path Length: the lower the AS_PATH number, the better the route.
- Origin Code: prefers the route with the smallest Origin IGP code. It is smaller than EGP, which in turn is smaller than INCOMPLETE.
- MED: the lower the MED value, the better the route.
- eBGP path over iBGP path: preference of eBGP routes over iBGP routes.
- Shortest IGP patch to BGP next hop: prefers the route through the nearest IGP neighbor.
- Oldest path: the older eBGP route is preferred.
- Router ID: prefers the route with the lowest neighbor Router ID.
- Neighbor IP address: the neighbor with the lowest IP address will have the preferred route.
Explaining a BGP attribute
We chose some attributes to give a brief explanation of usability, and today we will explain a little about the WEIGHT attribute.
This is a CISCO-specific attribute used to identify the best path to a destination prefix when there are more entries available in the routing table. In other words, when the routing table contains two identical prefixes with distinct paths, the Weight attribute selects the best path, leaving the others as a backup. The higher the weight value, the better the path for the manipulated prefixes.
The weight value ranges from 0 to 65535 and the default for a received route is always 0 (zero).
The weight is not propagated to other neighboring routers in BGP, with the manipulation remaining only “active” in the AS in which it was applied.

According to the image above, the AS 5 network is receiving a prefix (30.30.30.0/24) through two upstreams (AS 10 and AS 20). The AS 5 network administrator has decided that his preferred best path for this prefix is through the upstream AS 20, applying a weight value of 200, making the upstream AS 10 a backup.
* Lucas Moreira – NIS Specialist