# Administrative Distance

Usually, a company will only use a single IGP - usually OSPF or EIGRP.

However, in some rare cases, they might use two. For example, if two companies connect their networks to share information, two different routing protocols might be used.

The metric is used to compare routes **learned via the same routing protocol**.

Different routing protocols use other metrics, so they cannot be compared. For example, an OSPF route to 192.168.4.0/24 might have a metric of 30, while an EIGRP route to the same destination might have a metric of 33280. Which route is better? Which route should the router put in the route table?

The **administrative distance** (AD) is used to determine which routing protocol is preferred.

A lower AD is preferred and indicates that the routing protocol is considered more 'trustworthy' (more likely to select good routes).

| Route protocol/type | Administrative distance |
| ------------------- | ----------------------- |
| Directly connected  | 0                       |
| Static              | 1                       |
| External BGP (eBGP) | 20                      |
| EIGRP               | 90                      |
| IGRP                | 100                     |
| OSPF                | 110                     |
| IS-IS               | 115                     |
| RIP                 | 120                     |
| EIGRP (external)    | 170                     |
| Internal BGP (iBGP) | 200                     |
| Unusable route      | 255                     |

{% hint style="danger" %}
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.
{% endhint %}

## Example

The following routes to the destination network 10.1.1.0/24 are learned:

1. next hop 192.168.1.1, learned via RIP, metric 5.
2. next hop 192.168.2.1, learned via RIP, metric 3.
3. next hop 192.168.3.1, learned via OSPF, metric 10.

Which route to 10.1.1.0/24 will be added to the route table ?

The route discovered via OSPF will be added, as OSPF has a lower administrative distance than RIP.

## Static Route

You can change the AD of a routing protocol.

You can also change the AD of a static route.

<figure><img src="/files/0V37Tbmg03sMZKnucBTq" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://davidjosearaujo.gitbook.io/online-courses/ccna-200-301/dynamic-routing/administrative-distance.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
