When two protocols offer a route to the same prefix, the metrics cannot be compared, because a cost of ten in one protocol means nothing in another. Administrative distance is the tie break that resolves it.
Two properties are worth fixing in mind immediately. It is entirely local to the router, since it is never advertised and never carried in any packet. And a lower value wins, which is the opposite of how most people first read it.
Cisco defaults
| Source | Distance |
|---|---|
| Connected interface | 0 |
| Static route | 1 |
| EIGRP summary | 5 |
| External BGP | 20 |
| Internal EIGRP | 90 |
| OSPF | 110 |
| IS-IS | 115 |
| RIP | 120 |
| External EIGRP | 170 |
| Internal BGP | 200 |
| Unusable | 255 |
The two BGP values are the interesting pair. External is trusted above every interior protocol at twenty, on the reasoning that a route learned from another autonomous system describes reachability the interior protocol cannot know about.
Internal sits at two hundred, below everything, because a route learned from an internal peer has already been learned from outside by some other router in the domain, and the interior protocol is the better authority on how to reach that router.
The value is not portable
| Source | Cisco | Juniper | Nokia SR OS | Huawei |
|---|---|---|---|---|
| Term used | Distance | Preference | Preference | Preference |
| Connected | 0 | 0 | 0 | 0 |
| Static | 1 | 5 | 5 | 60 |
| OSPF internal | 110 | 10 | 10 | 10 |
| IS-IS level one | 115 | 15 | 15 | 15 |
| OSPF external | 110 | 150 | 150 | 150 |
| BGP | 20 or 200 | 170 | 170 | 255 |
Three differences matter in practice. Juniper and Nokia separate internal from external OSPF where Cisco does not, so a route redistributed into OSPF loses to an internal one automatically rather than requiring configuration.
Neither distinguishes external from internal BGP, giving both the same value, which means the selection between them happens inside the BGP process rather than at this layer. And Huawei places static routes at sixty rather than near zero, which is the single most surprising value on the table for anyone arriving from a Cisco background.
Where changing it is legitimate
A floating static route is the common and correct use. Configuring a static route with a distance higher than the dynamic protocol means it stays out of the table until the protocol withdraws the route, at which point it takes over. This is how backup paths over a secondary link are built without any protocol running across it.
Migration is the other. Raising the distance of the outgoing protocol while both run allows the new one to take over prefix by prefix, with the old one still present and immediately available if something is wrong.
Where changing it causes trouble
Because the value is local, changing it on one router and not another produces a routing table that differs between devices in the same domain, which is how forwarding loops are created between two routers that each believe the other is the better path.
The rule is that any change must be applied consistently across every device that could select between the same two sources, and that the reason must be recorded somewhere, since a non default value discovered years later is indistinguishable from a mistake.
Note: distance decides which route is installed, not which is best. A route with a poor metric from a trusted source beats an excellent metric from a less trusted one, and no comparison of the metrics ever takes place.