本文檔介紹如何配置IPv6的靜態路由。靜態路由是手動配置的路由,用於定義兩台裝置之間的顯式路徑。在網路拓撲發生變化時,靜態路由不會像動態協定那樣自動更新,必須手動重新配置。靜態路由適用於只有一條路徑通往外部網路的小型網路。
使用靜態路由的主要缺點是,在拓撲發生變化時缺少自動配置。靜態路由還用於為到需要更多控制的其它網路的某些型別的流量提供安全性。使用靜態路由時考慮到的限制是缺少冗餘,而在大型網路中,手動重新配置路由會增加大量的管理開銷。
使用ipv6 route 命令配置靜態路由。請注意,使用靜態IPv6路由配置路由器之前,必須在全域性配置模式下使用ipv6 unicast-routing 命令啟用IPv6資料包的轉發。
嘗試此組態之前,請確保符合以下要求:
IPv4靜態路由知識
IPv6編址方案知識
本檔案中的資訊是根據Cisco IOS®軟體版本12.4(15)T 13上的Cisco 3700系列路由器。
本文中的資訊是根據特定實驗室環境內的裝置所建立。文中使用到的所有裝置皆從已清除(預設)的組態來啟動。如果您的網路正在作用,請確保您已瞭解任何指令可能造成的影響。
如需文件慣例的詳細資訊,請參閱思科技術提示慣例。
本節提供用於設定本文件中所述功能的資訊。
註:使用Command Lookup Tool(僅限註冊客戶)查詢有關本文檔中使用的命令的更多資訊。
本檔案會使用以下網路設定:
本檔案會使用以下設定:
以下是Cisco支援社群 (Cisco Support Community)上提供的影片連結,該連結演示了如何在Cisco IOS路由器中為IPv6網路配置靜態路由:
路由器R1 |
---|
version 12.4 ! hostname R1 ! ip cef ! ipv6 unicast-routing !--- Enables the forwarding of IPv6 packets. ! interface Loopback1 no ip address ipv6 address 1010::1/128 ! interface FastEthernet0/0 no ip address duplex auto speed auto ipv6 address 2000::1/126 ! ip forward-protocol nd ! ipv6 route 2001::/126 2000::2 ipv6 route 2020::1/128 2000::2 ipv6 route 3030::1/128 2000::2 !--- Static routes are configured in router R1, !--- to reach the networks in router R2 and R3. !--- This is done when you specify !--- the next-hop address, which in this case is !--- 2000::2 from which the output interface !--- is automatically derived. ! end |
路由器R2 |
---|
version 12.4 ! hostname R2 ! ip cef ! ipv6 unicast-routing ! interface Loopback2 no ip address ipv6 address 2020::1/128 ! interface FastEthernet0/0 no ip address duplex auto speed auto ipv6 address 2000::2/126 ! interface FastEthernet0/1 no ip address duplex auto speed auto ipv6 address 2001::1/126 ! ip forward-protocol nd ! ipv6 route 1010::1/128 2000::1 ipv6 route 3030::1/128 2001::2 !--- Static routes are configured to reach !--- routers R1 and R3 loopback address when you !--- specify the corresponding interface address. ! end |
路由器R3 |
---|
version 12.4 ! hostname R3 ! ip cef ! ipv6 unicast-routing ! interface Loopback3 no ip address ipv6 address 3030::1/128 ! interface FastEthernet0/0 no ip address duplex auto speed auto ipv6 address 2001::2/126 ! ip forward-protocol nd ! ipv6 route 1010::1/128 2001::1 ipv6 route 2000::/126 2001::1 ipv6 route 2020::1/128 2001::1 !--- For router 3, to reach R1 and R2, !--- static routes are configured when you !--- mention 2001::1 as the next-hop address. ! end |
使用本節內容,確認您的組態是否正常運作。
輸出直譯器工具(僅供已註冊客戶使用)(OIT)支援某些show命令。使用OIT檢視show命令輸出的分析。
使用show ipv6 route static 命令顯示IPv6路由表的內容,其輸出如下所示:
show ipv6 route static |
---|
在路由器R1中 R1#show ipv6 route static IPv6 Routing Table - 7 entries Codes: C - Connected, L - Local, S - Static, R - RIP, B - BGP U - Per-user Static route, M - MIPv6 I1 - ISIS L1, I2 - ISIS L2, IA - ISIS interarea, IS - ISIS summary O - OSPF intra, OI - OSPF inter, OE1 - OSPF ext 1, OE2 - OSPF ext 2 ON1 - OSPF NSSA ext 1, ON2 - OSPF NSSA ext 2 D - EIGRP, EX - EIGRP external S 2001::/126 [1/0] via 2000::2 S 2020::1/128 [1/0] via 2000::2 S 3030::1/128 [1/0] via 2000::2 !--- Displays the static routes learnt by router R1 through 2000::2.路由器R3中 R3#show ipv6 route static IPv6 Routing Table - 7 entries Codes: C - Connected, L - Local, S - Static, R - RIP, B - BGP U - Per-user Static route, M - MIPv6 I1 - ISIS L1, I2 - ISIS L2, IA - ISIS interarea, IS - ISIS summary O - OSPF intra, OI - OSPF inter, OE1 - OSPF ext 1, OE2 - OSPF ext 2 ON1 - OSPF NSSA ext 1, ON2 - OSPF NSSA ext 2 D - EIGRP, EX - EIGRP external S 1010::1/128 [1/0] via 2001::1 S 2000::/126 [1/0] via 2001::1 S 2020::1/128 [1/0] via 2001::1 !--- Displays the static routes learnt by router R3 through 2001::1. |
路由器R1擁有通往路由器R2和R3的路由,因此路由器R1應該能夠ping通路由器R2的環回地址和路由器R3。使用ping命令檢驗相同路由。
在路由器R1中 |
---|
Ping路由器R2的環回地址 R1#ping 2020::1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 2020::1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 0/36/104 ms !--- Router R1 is successfully able to ping !--- router R2's loopback address.Ping路由器R3 R1#ping 2001::2 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 2001::2, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 12/40/116 ms R1#ping 3030::1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 3030::1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 8/32/84 ms !--- Similarly R1 is also able to reach R3, !--- for example, ping to R3's interface address !--- and loopback address from router R1 is successful. |
注意:同樣,路由器R3也可以到達路由器R1的Fa0/0地址2000::1及其環回地址1010::1。
使用show ipv6 static命令以顯示路由表的當前內容,並使用detail語法顯示更多有用資訊,如以下示例中所述:
show ipv6 static |
---|
在路由器R1中 R1#show ipv6 static IPv6 Static routes Code: * - installed in RIB * 2001::/126 via nexthop 2000::2, distance 1 * 2020::1/128 via nexthop 2000::2, distance 1 * 3030::1/128 via nexthop 2000::2, distance 1 !--- Displays the routes that are installed in !--- the IPv6 Routing Information Base(RIB) marked with *! |
指定detail關鍵字時,將顯示其他資訊。以下是輸出範例:
show ipv6 static detail |
---|
在路由器R2中 R2#show ipv6 static detail IPv6 Static routes Code: * - installed in RIB * 1010::1/128 via nexthop 2000::1, distance 1 Resolves to 1 paths (max depth 1) !--- Displays the output path set, and maximum !--- resolution depth, which in this case is 1. via FastEthernet0/0 * 3030::1/128 via nexthop 2001::2, distance 1 Resolves to 1 paths (max depth 1) via FastEthernet0/1 !--- Displays that the route is received through !--- the next-hop 2000::1 through interface fa0/0. |
注意:如果路由無效,將顯示以下資訊:
對於無效的遞迴路由,為路由無效的原因。
對於無效的直接或完全指定路由,說明該路由無效的原因。
修訂 | 發佈日期 | 意見 |
---|---|---|
1.0 |
19-Dec-2011 |
初始版本 |