Most routing tables contain a combination of directly connected routes, static routes, and dynamic routes. However, the routing table must first contain the directly connected networks that are used to access the remote networks before any static or dynamic routing can be used.
大多數路由表都包含直接連接路由、靜態路由與動態路由的組合。不過,在使用任何靜態或動態路由之前,路由表必須先包含用來存取遠端網路的直接連接網路。
Verifying Static Route Configuration
驗證靜態路由設定
A static route includes the network address and prefix of the remote network, along with the IPv4 address of the next-hop router or exit interface. Static routes are denoted with the code "S" in the routing table, as shown in the figure.
靜態路由包含遠端網路的網路位址與前綴,以及下一跳路由器或出口介面的 IPv4 位址。靜態路由在路由表中以代碼「S」標示,如圖所示。
If you configure a static route to use an egress interface instead of a next-hop IPv4 address, the routing table entry is changed accordingly.
如果將靜態路由設定為使用出口介面而非下一跳 IPv4 位址,路由表項目會相應改變。
For example, if this default route pointing to the exit interface (Serial0/0/1) is configured on router B:
例如,如果在路由器 B 上設定了這個指向出口介面(Serial0/0/1)的預設路由:
RouterB(config)# ip route 0.0.0.0 0.0.0.0 Serial0/0/1The corresponding routing table entry of the static route in the routing table of router B is:
路由器 B 路由表中該靜態路由對應的項目為:
RouterB# show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
+ - replicated route, % - next hop override
Gateway of last resort is 0.0.0.0 to network 0.0.0.0
S* 0.0.0.0/0 is directly connected, Serial0/0/1
172.16.0.0/16 is variably subnetted, 4 subnets, 2 masks
C 172.16.1.0/24 is directly connected, FastEthernet0/0
L 172.16.1.1/32 is directly connected, FastEthernet0/0
C 172.16.2.0/24 is directly connected, Serial0/0/1
L 172.16.2.1/32 is directly connected, Serial0/0/1Note that the entry in the routing table no longer refers to the next-hop IPv4 address but refers directly to the exit interface. This exit interface is the same one to which the static route was resolved when it used the next-hop IPv4 address. Now that the routing table process has a match for a packet and this static route, it is able to resolve the route to an exit interface in a single lookup.
請注意,路由表中的項目不再參照下一跳 IPv4 位址,而是直接參照出口介面。這個出口介面與先前使用下一跳 IPv4 位址時所解析出的出口介面相同。現在路由表處理程序只需一次查詢,就能將封包與此靜態路由比對,並解析出出口介面。
Verifying Default Route Configuration
驗證預設路由設定
To verify the default route configuration, examine the routing table on router B:
若要驗證預設路由設定,可檢視路由器 B 的路由表:
The example in the figure shows the router B routing table after configuration of the default route.
圖中的範例顯示設定預設路由後路由器 B 的路由表。
The asterisk (*) indicates that the route is a candidate default route.
星號(*)表示該路由是候選預設路由。