21 · Introducing OSPFOSPF 簡介

Path Selection路徑選擇

The router determines the best path to the destination network by evaluating the multiple available paths and choosing the optimal one to reach that network. If you want to control the choice of the best path to the network, you need to statically configure a route. When the router uses dynamic routing protocols, it chooses the best path by evaluating a value called metric, which quantifies the path to the destination network. (You will sometimes see that the metric referred to as distance.) A dynamic routing protocol’s best path to a network is the path with the lowest metric. Dynamic routing protocols use their own rules and metrics. Each dynamic protocol offers its best path (its lowest metric route) to the routing table.

路由器透過評估多條可用路徑,選出最佳的一條來決定通往目的地網路的最佳路徑。如果你想要控制到該網路的最佳路徑選擇,就需要靜態設定一條路由。當路由器使用動態路由協定時,它會透過評估一個稱為度量值的數值來選擇最佳路徑,度量值用來量化到目的地網路的路徑(有時你會看到度量值也被稱為距離)。動態路由協定到某網路的最佳路徑,就是度量值最低的路徑。每種動態路由協定都有自己的規則與度量值,各自會將其最佳路徑(度量值最低的路由)提供給路由表。

In an enterprise network, it is not uncommon to encounter multiple dynamic routing protocols and static routes configured. If this occurs, the routing table may have more than one route source (a connected route, a static route, and a dynamic route) for the same destination network. Cisco IOS Software uses the administrative distance to determine the route to install into the IP routing table. The administrative distance represents the "trustworthiness" of the source of the route; the lower the administrative distance, the more trustworthy the route source. For example, a static route has a default administrative distance of 1, whereas an OSPF-learned route has a default administrative distance of 110. Given separate routes to the same destination with different administrative distances, the router chooses the route with the lowest administrative distance. Administrative distance is used as a tie breaker only when different sources offer the information for the same destination network, that is, the same network address and subnet mask.

在企業網路中,同時設定多種動態路由協定與靜態路由的情況並不少見。若發生這種情況,路由表對同一個目的地網路可能會有多個路由來源(直接連接路由、靜態路由及動態路由)。Cisco IOS 軟體會使用管理距離來決定要安裝到 IP 路由表中的路由。管理距離代表路由來源的「可信度」:管理距離越低,路由來源越可信。舉例來說,靜態路由的預設管理距離為 1,而 OSPF 學習到的路由預設管理距離為 110。當有多條到達同一目的地、但管理距離不同的個別路由時,路由器會選擇管理距離最低的路由。管理距離只有在不同來源提供相同目的地網路(即相同網路位址與子網路遮罩)的資訊時,才會作為決勝依據。

The administrative distance is an integer from 0 to 255. A routing protocol with a lower administrative distance is considered more trustworthy than one with a higher administrative distance.

管理距離是介於 0 到 255 之間的整數。管理距離較低的路由協定,會被視為比管理距離較高的協定更值得信任。

In the figure, the router has received two routing update messages—one from OSPF and one from EIGRP. The metric that EIGRP uses has determined that the best path to network 172.17.8.0/24 is via 192.168.5.2, but the metric that OSPF uses has determined that the best path to 172.17.8.0/24 is via 192.168.3.1. Each routing protocol uses a different metric to calculate the best path to a given destination, if it learns multiple paths to the same destination.

在圖中,路由器收到了兩則路由更新訊息,一則來自 OSPF,一則來自 EIGRP。EIGRP 使用的度量值判斷出到網路 172.17.8.0/24 的最佳路徑是經由 192.168.5.2,而 OSPF 使用的度量值則判斷出到 172.17.8.0/24 的最佳路徑是經由 192.168.3.1。若每種路由協定學習到多條通往同一目的地的路徑,各協定會使用不同的度量值來計算最佳路徑。

The router has used the administrative distance feature to determine which route to install in its routing table. Because the administrative distance for OSPF is 110 and the administrative distance for EIGRP is 90, the router has chosen the EIGRP route and adds only the EIGRP route to its routing table.

路由器使用管理距離特性來決定要在路由表中安裝哪條路由。由於 OSPF 的管理距離為 110,而 EIGRP 的管理距離為 90,因此路由器選擇了 EIGRP 路由,只將該路由加入路由表。

The table shows the default administrative distance for selected routing information sources.

下表顯示部分路由資訊來源的預設管理距離。

Route Source
路由來源
Default Administrative Distance
預設管理距離
Connected interface (and static routes via interface)
直接連接介面(及經介面設定的靜態路由)
0
0
Static route (via next hop address)
靜態路由(經由下一跳位址)
1
1
External Border Gateway Protocol (EBGP)
外部邊界閘道協定(EBGP)
20
20
EIGRP
EIGRP
90
90
OSPF
OSPF
110
110
IS-IS
IS-IS
115
115
RIP
RIP
120
120
External EIGRP
外部 EIGRP
170
170
Internal Border Gateway Protocol (IBGP)
內部邊界閘道協定(IBGP)
200
200
Unreachable
不可達
255 (will not be used to pass traffic)
255(不會用來傳送流量)
Which route is preferred by a router when the router is comparing them using default administrative distances?當路由器使用預設管理距離比較路由時,會偏好哪一條路由?