13 · Exploring the Functions of Routing探索路由的功能

Path Determination路徑決定

Determining the best path involves evaluating multiple paths to the same destination network and selecting the optimum path to reach that network. When you statically configure a route, then you determine what the best path to the network is. But when dynamic routing protocols are used, the best path is selected by a routing protocol based on the quantitative value called a metric. A metric is a quantitative value used to measure how to get to a given network. A dynamic routing protocol's best path to a network is the path with the lowest metric.

決定最佳路徑,是指評估到達同一目的網路的多條路徑,並選出到達該網路的最佳路徑。當您手動設定靜態路由時,是由您自己決定到該網路的最佳路徑為何。但當使用動態路由協定時,最佳路徑是由路由協定根據一個稱為度量值(metric)的量化數值來選出。度量值是用來衡量如何到達某個網路的量化數值。動態路由協定到某網路的最佳路徑,就是度量值最低的路徑。

Dynamic routing protocols typically use their own rules and metrics. The routing algorithm calculates a metric for each path to the destination network. Metrics can be based on either a single characteristic, such as bandwidth, or several characteristics of a path, such as bandwidth, delay, and reliability. Some routing protocols can base route selection on multiple metrics, combining them into a single metric.

動態路由協定通常使用各自的規則與度量值。路由演算法會為到目的網路的每條路徑計算一個度量值。度量值可以只根據單一特性(例如頻寬),也可以根據路徑的多項特性(例如頻寬、延遲與可靠性)。有些路由協定可以將路由選擇建立在多個度量值上,並將它們合併為單一度量值。

Review the example topology in the following figure.

請檢視下圖的範例拓樸。

Router R1 has multiple paths to LAN B network. One possible path is R1 > R2 > R3. An alternative path is R1 > R3. If router R1 runs a routing protocol that uses "hop count" as a metric, that protocol will count how many routers there are to the destination. R1 router would choose the path R1 > R3, because there is only one router on that path to the LAN B. An example of a protocol that uses hop count as a metric is RIP.

路由器 R1 有多條路徑可到達 LAN B 網路。其中一條可能的路徑是 R1 > R2 > R3,另一條替代路徑是 R1 > R3。如果路由器 R1 執行的路由協定使用「跳數」作為度量值,該協定會計算到目的地要經過幾台路由器。R1 會選擇 R1 > R3 這條路徑,因為到 LAN B 的這條路徑上只有一台路由器。使用跳數作為度量值的協定範例是 RIP。

OSPF and EIGRP routing protocols do not count routers, but both take into consideration the bandwidth of the links on the path to the destination. In the example in the figure, when bandwidth is considered, then R1 > R2 > R3 path along 1-Gbps links is a better path than R1 > R3 with the bandwidth of 100 Mbps.

OSPF 與 EIGRP 路由協定不計算路由器數量,但兩者都會考量到目的地路徑上各連結的頻寬。在圖中的範例中,考量頻寬時,沿著 1 Gbps 連結的 R1 > R2 > R3 路徑,會比頻寬為 100 Mbps 的 R1 > R3 路徑更好。

Each dynamic protocol offers its best path (its lowest metric route) to the routing table.

每個動態協定都會將其最佳路徑(度量值最低的路由)提供給路由表。

Administrative Distance

管理距離

Routing tables can be populated from three sources: directly connected networks, static routes, and routing protocols. The router must evaluate the routing information from all the sources and select the best route to each destination network to install into the routing table.

路由表可以由三種來源填入:直接連接的網路、靜態路由,以及路由協定。路由器必須評估來自所有來源的路由資訊,並為每個目的網路選出最佳路由安裝到路由表中。

A router can be configured with multiple routing protocols and static routes. The routing table may have more than one route source for the same destination network if this occurs. Cisco IOS Software uses what is known as the administrative distance to determine the route to install into the IP routing table. The administrative distance represents the "trustworthiness" 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.

路由器可以同時設定多種路由協定與靜態路由。若發生這種情況,路由表對於同一個目的網路可能會有一個以上的路由來源。Cisco IOS 軟體使用所謂的管理距離,來決定要安裝到 IP 路由表中的路由。管理距離代表該路由的「可信度」,管理距離越低,該路由來源就越值得信任。舉例來說,靜態路由預設的管理距離為 1,而透過 OSPF 學習到的路由預設管理距離為 110。若到同一目的地有多條管理距離不同的個別路由,路由器會選擇管理距離最低的路由。

Administrative distance is used as a tiebreaker only when different sources offer the information for the same destination network, that is, the same network address and subnet mask. For example, suppose both static and dynamic route sources offer information for the 172.16.1.0/24 network. In that case, the administrative distance will decide whether a static or dynamic entry will be installed in the routing table. But, if the static route source offers information for 172.16.0.0/16 and the dynamic route source offers information for 172.16.1.0/24, then these are considered different routes, and there is no need for an administrative distance to break a tie.

管理距離只有在不同來源提供相同目的網路(也就是相同的網路位址與子網路遮罩)的資訊時,才會用來當作決勝依據。舉例來說,假設靜態與動態路由來源都提供了 172.16.1.0/24 網路的資訊,這種情況下,管理距離就會決定要在路由表中安裝靜態項目還是動態項目。但如果靜態路由來源提供的是 172.16.0.0/16 的資訊,而動態路由來源提供的是 172.16.1.0/24 的資訊,這兩者會被視為不同的路由,就不需要用管理距離來決勝。

When a router chooses a static route and an OSPF route, the static route takes precedence. Similarly, a directly connected route with an administrative distance of 0 takes precedence over a static route with an administrative distance of 1.

當路由器要在靜態路由與 OSPF 路由之間做選擇時,靜態路由優先。同樣地,管理距離為 0 的直接連接路由,會優先於管理距離為 1 的靜態路由。

Each source type has a default administrative distance. The figure lists several routing sources and their associated administrative distances. The values in the table are default values, which can be changed.

每種來源類型都有預設的管理距離。下圖列出幾種路由來源及其對應的管理距離。表中的數值為預設值,可以被更改。

Route Source
路由來源
Default Administrative Distance
預設管理距離
Connected
直接連接
0
0
Static
靜態
1
1
EIGRP
EIGRP
90
90
OSPF
OSPF
110
110

Keep in mind these takeaways regarding routing table sources:

關於路由表來源,請記住以下重點:

  • Directly connected networks have an administrative distance of 0 and preempt all other entries for that destination network. Only a directly connected route can have an administrative distance of 0 and the administrative distance of 0 cannot be modified for directly connected networks.直接連接的網路管理距離為 0,會優先於該目的網路的所有其他項目。只有直接連接的路由才能有 0 的管理距離,且直接連接網路的管理距離 0 無法被修改。
  • Static routes have a default administrative distance of 1; therefore, if you configure a static route, it will be included in the routing table unless there is a direct connection to the destination network.靜態路由預設的管理距離為 1;因此,若您設定了靜態路由,除非該目的網路有直接連接,否則此靜態路由就會被納入路由表中。
  • Each routing protocol has its default administrative distance. The OSPF administrative distance is 110. The administrative distance of the EIGRP protocol is 90.每種路由協定都有其預設的管理距離。OSPF 的管理距離為 110,EIGRP 協定的管理距離為 90。
  • The route is determined based on the prefix, which means that routes 10.0.10.0/24 and 10.0.10.0/28 are not the same route if sourced from different sources and would, therefore, both be installed in the routing table.路由是依前綴來判斷的,這表示如果 10.0.10.0/24 與 10.0.10.0/28 這兩條路由來自不同來源,就不算是同一條路由,因此兩者都會被安裝到路由表中。

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 路由,並只將該 EIGRP 路由加入其路由表中。

Route Selection in Cisco Routers

Cisco 路由器的路由選擇

After installing route entries in the routing table, the routing table may contain entries for a destination network and subnets. For example, the routing table may contain an entry for 10.0.0.0/8 but also entries for subnets of that network, that is, 10.10.0.0/16, 10.10.1.0/24, and 10.10.2.0/24.

在路由項目安裝到路由表後,路由表中可能同時包含某個目的網路以及其子網路的項目。舉例來說,路由表中可能有一筆 10.0.0.0/8 的項目,也同時有該網路子網路的項目,也就是 10.10.0.0/16、10.10.1.0/24 與 10.10.2.0/24。

When a router receives a packet, it looks at the routing table to determine how to forward it to the final destination. The router always tries to find an exact match for the destination IPv4 address included in the IPv4 header of the packet, but very rarely does such a route exist in the routing table; therefore, the router looks for the router best match.

當路由器收到封包時,會查看路由表以決定如何將其轉送到最終目的地。路由器一律會嘗試為封包 IPv4 標頭中的目的 IPv4 位址找出完全相符的項目,但路由表中極少存在這樣的路由;因此路由器會尋找路由器最佳比對項目。

Because each entry in a routing table may specify a subnetwork, a packet's destination address may match more than one routing table entry. For instance, a packet destined to 10.10.2.3 would match entries 10.0.0.0/8, 10.10.0.0/16, and 10.10.2.0/24. Although all three routes match the destination address, they do not match it in the same way. The 10.10.2.3 destination IPv4 address matches the 10.0.0.0/8 destination network only in the first 8 bits. The 10.10.2.3 destination IPv4 address matches the 10.10.0.0/16 destination network only in the first 16 bits. Finally, the 10.10.2.3 destination IPv4 address matches the 10.10.2.0/24 destination network in the first 24 bits. The routing table entry whose leading address bits matches the largest number of the packet destination address bits is called the longest prefix match. In this example, 10.10.2.0/24 is the longest prefix match.

由於路由表中的每筆項目都可能代表一個子網路,一個封包的目的位址可能會符合路由表中的多筆項目。例如,一個目的地為 10.10.2.3 的封包,會符合 10.0.0.0/8、10.10.0.0/16 及 10.10.2.0/24 這三筆項目。雖然這三條路由都符合此目的位址,但符合的程度並不相同。目的 IPv4 位址 10.10.2.3 只在前 8 個位元與目的網路 10.0.0.0/8 相符;只在前 16 個位元與目的網路 10.10.0.0/16 相符;最後,在前 24 個位元與目的網路 10.10.2.0/24 相符。在路由表項目中,前導位址位元與封包目的位址位元相符數量最多的項目,稱為最長前綴比對。在此範例中,10.10.2.0/24 就是最長前綴比對。

The longest prefix match always wins among the routes installed in the routing table, that is, among entries already in the routing table.

在已安裝於路由表中的路由(也就是路由表中既有的項目)之間,最長前綴比對永遠優先。

The figure shows a routing table in which the longest match for 10.0.0.1 is a /32 route (called host route). Even if the shortest path for the packet destined to the PC appears to be forwarding the packet directly to the PC out of interface G0/0, the packet is instead forwarded to a different path according to the longest match rule.

圖中顯示的路由表中,10.0.0.1 的最長比對項目是一筆 /32 路由(稱為主機路由)。即使看起來將目的地為該 PC 的封包,直接從介面 G0/0 轉送給該 PC 是最短路徑,但依據最長比對規則,該封包實際上會被轉送到另一條路徑。

Making a forwarding decision consists of three sets of processes: the routing processes, the routing table, and the actual process that makes the forwarding decision and switches packets.

轉送決策包含三組流程:路由流程、路由表,以及實際做出轉送決策並交換封包的流程。

Three processes are involved in building and maintaining the routing table in a Cisco router:

建立與維護 Cisco 路由器路由表,共牽涉三個流程:

  • Various routing processes, which actually run a routing protocol, such as RIP version 2 (RIPv2), EIGRP, IS-IS, and OSPF. The best route from a routing process has the potential to be installed into the routing table. The routing protocol with the lowest administrative distance always wins when installing routes into the routing table.各種路由流程,實際執行某種路由協定,例如 RIP 第 2 版(RIPv2)、EIGRP、IS-IS 及 OSPF。來自某個路由流程的最佳路由,有可能被安裝到路由表中。在將路由安裝到路由表時,管理距離最低的路由協定永遠會勝出。
  • The routing table itself, which accepts information from the routing processes and also replies to requests for information from the forwarding process.路由表本身,它接收來自路由流程的資訊,也會回應轉送流程對資訊的請求。
  • The forwarding process, which requests information from the routing table to make a packet forwarding decision.轉送流程,它會向路由表請求資訊,以做出封包轉送決策。
Which statement about the administrative distance feature of Cisco routers is correct?關於 Cisco 路由器的管理距離功能,下列哪一項敘述是正確的?