When a router has to forward a packet, it looks in its routing table to match as many bits as possible of the destination address to a route in its routing table. This is known as longest match routing.
Once a match is found, the router forward the packet to the next hop defined by that routing entry.
Things get interesting when there are more than one route to a given destination network. Depending on what routing protocol is used, each possible next hop path is going to have a “cost”. With distance vector protocols such as RIP, this cost is a simple count of the number of hops (i.e. if I go this way it is 5 hops, if I go that way it is 6 hops). With link state protocols such as OSPF, the cost is a number related to the bandwidth of the link.
Things get more interesting when a router is using multiple routing protocols that have different shortest path calculations (i.e. OSPF says go this way for that destination with a cost of X, and BGP says go that way for the same destination and the same cost of X). This is considered a tie! So what happens?
The bottom line is there has to be a tie breaker. this tie breaker is called the Administrative Cost. The administrative costs are used along side the normal metric in case of ties. They are preprogrammed into IOS. The lower the administrative metric the more preferred it is.
Here are the default administrative distances:
|IP Route||Administrative Distance|
|Directly connected interface||0|
|Static route using connected interface||0|
|Static route using IP address||1|
|EIGRP summary route||5|
|External BGP route||20|
|Internal EIGRP route||90|
|External EIGRP route||170|
|Internal BGP route||200|
|Route of unknown origin||255|
If the administrative distance is 255, the router does not believe the source of that route and does not install the route in the routing table.
Using the example mentioned above where both BGP and OSPF have a “tie”, you can see above that due to the administrative costs, the BGP route will be preferred, breaking the tie.
You can override the administrative distances by adding the ‘distance’ command under the protocol:
CellRouter(config)#router ospf 1
An often confusing issue (even wrong on the Cisco chat boards) is confusing Administrative Distance with Cost. For example, Cost of a route can be configured using ip route command:
ip route 18.104.22.168 255.255.255.0 22.214.171.124 85 (where 85 is the cost)
This is NOT the administrative distance. Statis routes such as the ip route above always have an administrative distance of 1.
We hope that iron’s out the explanation of Administraive Distance.