After the PrefVals of BGP routes are set, the route with the greatest PrefVal is selected when multiple routes to the same destination exist in the BGP routing table.
The Multi_Exit Discriminator (MED) attribute equals a metric used in an IGP. The MED attribute is used to determine the optimal route for traffic that enters an AS. The route with the smallest MED value is selected as the optimal route if the other attributes of the routes are the same.
The configuration of the next hop affects whether the next hop is set to the address of the router itself. BGP has certain common rules. Whether the next hop address is reachable is the first matching point in BGP route selection.
Configuring the AS-Path attribute can prevent loop in BGP. BGP checks the AS-Path attribute of the route sent from the peer. If the local AS number already exists, BGP ignores the route.