本檔案將說明no ip classless和預設路由之間的互動導致的ICMP來源位址選擇例外疑難排解。
思科建議您瞭解以下主題:
本文中的資訊係根據以下軟體和硬體版本:
本文中的資訊是根據特定實驗室環境內的裝置所建立。文中使用到的所有裝置皆從已清除(預設)的組態來啟動。如果您的網路運作中,請確保您瞭解任何指令可能造成的影響。
附註:Cisco建議保持預設的ip classless配置,以避免無ip classless對路由查詢和本地流量源地址選擇產生意外的影響。
在C8500L路由器上,預設路由是通過BGP獲取的,預設路由的下一跳指向公共網路出口。
直接執行命令時:
C8500L# ping 8.8.8.8
裝置不會選擇公共網路送出介面地址作為ICMP回應的源地址,而是選擇內部介面地址(例如192.168.72.208)。 由於此內部地址無法通過公共網路正確返回,因此Ping失敗。
但是,對於另一個也依賴於預設路由的公有地址,例如:
C8500L# ping 10.10.10.10
裝置可以正確選擇公共網路送出介面地址作為源地址,Ping操作成功。

C8500L配置:
interface TenGigabitEthernet0/1/0
no ip address
!
interface TenGigabitEthernet0/1/0.490
encapsulation dot1Q 490
ip address 172.16.119.30 255.255.255.252
!
interface TenGigabitEthernet0/1/0.2190
encapsulation dot1Q 2190
ip address 172.16.0.58 255.255.255.252
ip nat outside
!
interface TenGigabitEthernet0/1/1
no ip address
!
interface TenGigabitEthernet0/1/1.5
encapsulation dot1Q 5
ip address 192.168.72.208 255.255.255.192
!
interface TenGigabitEthernet0/1/1.1011
encapsulation dot1Q 1011
ip address 192.168.197.184 255.255.255.0
no ip proxy-arp
ip nat inside
ip tcp adjust-mss 1300
!
!
no ip classless
ip forward-protocol nd
!
router bgp 65001
bgp log-neighbor-changes
neighbor 10.1.1.2 remote-as 65002
C8500L#show ip route bgp
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, m - OMP
n - NAT, Ni - NAT inside, No - NAT outside, Nd - NAT DIA
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
H - NHRP, G - NHRP registered, g - NHRP registration summary
o - ODR, P - periodic downloaded static route, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
& - replicated local route overrides by connected
Gateway of last resort is 172.28.0.57 to network 0.0.0.0
B* 0.0.0.0/0 [20/0] via 172.28.0.57, 6d22h
8.0.0.0/8 is variably subnetted, 5 subnets, 3 masks
B 8.x.203.0/24 [20/0] via 10.1.1.2, 3d17h
B 8.x.0.0/16 [20/0] via 10.1.1.2, 6d22h
B 8.x.0.0/17 [20/0] via 10.1.1.2, 6d22h
B 8.x.0.0/17 [20/0] via 10.1.1.2, 6d22h
B 8.x.0.0/16 [20/0] via 10.1.1.2, 6d22h
C8500L#show ip route 8.8.8.8
% Subnet not in table
C8500L#show ip route 10.10.10.10
% Network not in table
C8500L#show ip cef 0.0.0.0/0 detail
0.0.0.0/0, epoch 2, flags [rib only nolabel, rib defined all labels, default route]
recursive via 172.16.0.57
attached to TenGigabitEthernet0/1/0.2190
C8500L#show ip cef 8.8.8.8 detail
0.0.0.0/0, epoch 2, flags [rib only nolabel, rib defined all labels, default route]
recursive via 172.16.0.57
attached to TenGigabitEthernet0/1/0.2190
C8500L#show ip cef 10.10.10.10 detail
0.0.0.0/0, epoch 2, flags [rib only nolabel, rib defined all labels, default route]
recursive via 172.16.0.57
attached to TenGigabitEthernet0/1/0.2190
C8500L#show ip cef exact-route 172.16.0.54 8.8.8.8
172.28.0.54 -> 8.8.8.8 =>IP adj out of TenGigabitEthernet0/1/0.2190, addr 172.16.0.57
C8500L#show ip cef exact-route 172.16.0.54 10.10.10.10
172.28.0.54 -> 10.10.10.10 =>IP adj out of TenGigabitEthernet0/1/0.2190, addr 172.16.0.57
C8500L#show ip cef exact-route 192.168.72.208 8.8.8.8
10.0.72.208 -> 8.8.8.8 =>IP adj out of TenGigabitEthernet0/1/0.2190, addr 172.16.0.57
C8500L#show ip cef exact-route 192.168.72.208 10.10.10.10
10.0.72.208 -> 10.10.10.10 =>IP adj out of TenGigabitEthernet0/1/0.2190, addr 172.16.0.57
範例:
C8500L# ping 8.8.8.8
Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 8.8.8.8, timeout is 2 seconds: ..... Success rate is 0 percent (0/5)
debug ip packet output:
IP: s=192.168.72.208 (local), d=8.8.8.8 (WAN-interface)
預期的正常行為:
實際行為:
範例:
C8500L# ping 10.10.10.10
Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.10.10.10, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 62/62/63 ms
debug ip packet output:
IP: s=172.16.0.58 (local), d=10.10.10.10 (WAN-interface)
正常效能:
對於8.8.8.8,由於RIB中存在8.0.0.0/8的主要網路資訊,因此在啟用no ip classless後,路由器首先執行有類查找:
在no ip classless方案中,雖然路由器可以識別預設路由,但後續的RIB第一跳查詢驗證通常無法返回與轉發路徑相關的介面資訊。內部查詢過程最終返回空結果(NULL)。
當本地生成的流量無法從RIB第一躍點查詢中獲得正確的傳出介面關聯資訊時,源地址選擇邏輯將恢復為預設介面選擇機制。
此回退機制不保證所選地址與實際FIB傳出介面一致。因此,它可以選擇任何可用的本地介面地址,如內部LAN介面地址。
結果,看似矛盾的結果出現了:
這是Ping故障的直接原因。
C8500L#show ip route 8.0.0.0 255.0.0.0 longer-prefixes
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, m - OMP
n - NAT, Ni - NAT inside, No - NAT outside, Nd - NAT DIA
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
H - NHRP, G - NHRP registered, g - NHRP registration summary
o - ODR, P - periodic downloaded static route, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
& - replicated local route overrides by connected
Gateway of last resort is 172.16.0.57 to network 0.0.0.08.0.0.0/8 is variably subnetted, 5 subnets, 3 masks
B 8.x.203.0/24 [20/0] via 10.1.1.2, 3d17h
B 8.x.0.0/16 [20/0] via 10.1.1.2, 6d22h
B 8.x.0.0/17 [20/0] via 10.1.1.2, 6d22h
B 8.x.0.0/17 [20/0] via 10.1.1.2, 6d22h
B 8.x.0.0/16 [20/0] via 10.1.1.2, 6d22h
C8500L#show ip route 10.0.0.0 255.0.0.0 longer-prefixes
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, m - OMP
n - NAT, Ni - NAT inside, No - NAT outside, Nd - NAT DIA
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
H - NHRP, G - NHRP registered, g - NHRP registration summary
o - ODR, P - periodic downloaded static route, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
& - replicated local route overrides by connected
Gateway of last resort is 172.16.0.57 to network 0.0.0.0
因此,此問題的發生並不是隨機的。相反,這取決於路由表中是否存在對應於目標地址的有類主網路,以及是否存在匹配的更具體的子網路由。
刪除no ip classless並恢復無類路由查詢:
C8500L#configure terminal
C8500L(config)#ip classless
C8500L(config)#end
附註:在Cisco IOS XE上,ip classless通常是預設行為。如果運行配置中明確沒有ip classless,則執行ip classless可以恢復建議行為。
如果無法立即修改no ip classless,則可以顯式指定特定本地應用程式的源介面,例如:
C8500L(config)#ip domain lookup source-interface
C8500L(config)#ip http client source-interface
對於Ping測試,可以手動指定源地址:
C8500L#ping 8.8.8.8 source
或者,為特定地址配置靜態路由表示特定目標地址的臨時/指令旁路解決方案。
C8500L(config)#ip route 8.8.8.8 255.255.255.255 TenGigabitEthernet0/1/0.2190 172.16.0.57
這些方法只能解決特定應用或單一測試的源地址問題,不能取代無類no ip的刪除。
顯示技術支援路由詳細資訊
主要影響是不明確指定源地址的本地生成的流量,例如:
通常不會直接影響:
但是,具體影響仍取決於網路回傳路徑、NAT策略、ACL和安全策略。因此,建議在生產網路中完全驗證關鍵管理平面和控制平面通訊。
在具有預設路由和多個介面地址的網路中,no ip classless命令可以阻止正確檢索與特定目標地址的有類路由的實際轉發路徑相關的介面資訊。
發生這種情況時,裝置上本地生成的流量的源地址選擇可以恢復為非路徑相關的介面選擇邏輯,從而導致本地流量(例如,使用不正確的源IP執行Ping)。如果來源IP沒有公共可達性或正確的回傳路徑,則通訊可能會失敗。
| 修訂 | 發佈日期 | 意見 |
|---|---|---|
1.0 |
04-Sep-2026
|
初始版本 |