第五章 IP路由
5.1 查找路由條目
提問 在路由表中查找特定的路由條目
回答
Router>show ip route 172.25.100.15
Routing entry for 172.25.100.0/24
Known via "ospf 55",distance 110,metric 11,type inter area
Redistributing via ospf 55
Last update from 172.25.1.1 on Ethernet0,2d12h ago
Routing Descriptor Blocks:
*172.25.1.1,from 172.25.1.1,2d12h ago,via Ethernet0
Route metric is 11,traffic share count is 1
注釋 路由器在路由表中查找路由條目的原則是最長匹配,所以例子中雖然查找的是172.25.200.15但是由于沒有這條特定的路由,顯示的結果是最長匹配的172.15.100.024。如果沒有任何一條匹配只能使用缺省路由,會出現下面信息
Router>show ip route 172.15.101.5
% Network not in table
注意的是這里都是無類路由,如果有類的就不一樣了
5.2 查找特定類型的路由條目
提問 在路由表中查找相同類型的路由條目
回答
Router>show ip route static
192.168.1.0/32 is subnetted,1 subnets
S 192.168.1.1[1/0] via 172.25.1.4
還有一個更有用的命令
Router>show ip route summary
IP routing table name is Default-IP-Routing-Table(0)
Route Source Networks Subnets Overhead Memory (bytes)
connected 0 3 328 432
static 1 0 64 144
ospf 55 1 3 256 576
Intra-area:1 Inter-area:2 External-1:1 External-2:0
NSSA External-l:0 NSSA External-2:0
internal 2 2328
Total 4 6 648 3480
注釋 通過顯示路由表的統計情況來了解當前路由器的路由條目,也可以用來以后的比對
5.3 各種掩碼的轉換
注釋 腳本略去,建議使用Boson提供的免費轉換工具
5.4 使用靜態路由
提問 配置靜態路由
回答
Router#configure terminal
Enter configuration commands,one per line.End with CNTL/Z.
Router(config)#ip route 10.35.15.5 255.255.255.255 Ethernet0 (permanent選項可以使此條目一直存在于路由表中,而不管下一跳的可達性)
Router(config)#ip route 172.16.0.0 255.255.0.0 10.35.6.1 2(permanent)
Router(config)#end
Router#
也可以給路由條目打上標簽
Router#configure terminal
Enter configuration commands,one per line.End with CNTL/Z.
Router(config)#ip route 172.16.0.0 255.255.0.0 10.35.6.1 2 tag 36291
Router(config)#end
Router#
注釋 在類似以太網這種多路訪問的網絡中建議使用下一跳為地址而不是接口。正常情況下路由器對靜態路由的下一跳有效的檢查是一分鐘,在12.3(10)以后增加了下面的命令可以對此時間進行調整Router(congfig)#ip route static adjust-time 30.對靜態路由打tag用于路由再發布時的區分
5.5 浮動靜態路由
提問 當動態路由出問題的時候使用靜態路由作為備份
回答
Router#configure terminal
Enter configuration commands,one per line.End with CNTL/Z.
Router(congif)#ip route 10.0.0.0 255.0.0.0 172.16.1.1 190(下一跳也可以觸發一個撥號接口)
Router(config)#end
Router#
注釋 通過調整管理距離的方式來進行路由備份,不過要注意的是管理距離只適合在相同路由的情況下,路由條目的最長匹配是第一位的。另外在不同廠商設備互聯的時候,調整管理距離一定要設置合理。
5.6 基于源地址的策略路由
提問 根據地址的不同選擇不同的路徑
回答
Router#configure terminal
Enter configuration commands,one per line.End with CNTL/Z.
Router(config)#access-list 1 permit 10.15.35.0 0.0.0.255
Router(config)#access-list 2 permit 10.15.36.0 0.0.0.255
Router(config)#interface Ethernet0
Router(config-if)#ip address 10.15.22.7 255.255.255.0
Router(config-if)#ip policy route-map Engineers
Router(config-if)#ip route-cache policy
Router(config-if)#exit
Router(config)#route-map Engineers permit 10
Router(config-route-map)#match ip address 1
Router(config-route-map)#set ip next-hop 10.15.27.1
Router(config-route-map)#exit
Router(config)#route-map Engineers permit 20
Router(config-route-map)#match ip address 2
Router(config-route-map)#set interface Ethernet1
Router(config-route-map)#end
Router#
注釋 缺省情況下route map 的最后一句都是deny all,這樣不符合route map規則的數據包都會按照正常的路由表進行轉發。set ip next-hop verify-availability命令提供了對下一跳的驗證,不過是基于CDP的,所以如果使用此命令需要打開CDP,最好同時調整時長,畢竟缺省是180秒。在使用策略路由時會在排錯時增加難度,因為缺省對于本路由器發出的數據包可以繞過route map這樣造成錯覺。
5.7基于應用的策略路由
提問 根據不同的應用來選擇不同的路徑
回答
Router#configure terminal
Enter configuration commands,one per line.End with CNTL/Z
Router(config)#access-list 101 deny tcp 10.15.25.0 0.0.0.255 any eq www
Router(config)#access-list 101 permit tcp any any eq www
Router(config)#interface Ethernet0
Router(config-if)#ip address 10.15.22.7 255.255.255.0
Router(config-if)#ip policy route-map Websurfers
Router(config-if)#ip route-cache policy
Router(config-if)#exit
Router(config)#route-map Websurfers permit 10
Router(config-route-map)#match ip address 101
Router(config-route-map)#set ip next-hop 10.15.27.1
Router(config-route-map)#exit
Router(config)#route-map Websurfers permit 20
Router(config-route-map)#set ip default next-hop 10.15.26.1
Router(config-route-map)#end
Router#
對于本設備的發出的數據包也使用策略路由
Router#configure terminal
Enter configuration commands,one per line.End with CNTL/Z.
Router(config)#ip local policy route-map dlswtraffic
Router(config)#access-list 103 permit tcp any any eq 2065
Router(config)#access-list 103 permit tcp any eq 2065 any
Router(config)#route-map dlswtraffic permit 10
Router(config-route-map)#match ip address 103
Router(config-route-map)#set ip next-hop 10.15.27.3
Router(config-route-map)#end
Router#
注釋 正常情況下如果所有定義的下一跳都不存在的情況下會使用路由表來查詢,如果路由表沒有此定義會使用缺省路由,這時候你可以使用set ip default next-hop來定義一個不同的缺省路由
- 北京機房搬遷改造公司,系統集成有哪些公司?-2019-11-04
- 如何打造一個安全的網絡環境?政府要做到這四點-2019-11-04
- 北京辦公室網絡布線,綜合布線施工價格-2019-11-04
- 深信服產品專業上網行為管理,安全設備有保障-2019-11-04
- 兩年內網絡安全市場規模將達千億級別?來看看詳細分析-2019-11-04
- 北京炫億時代專業機房設備除塵,機房網絡改造-2019-11-04
- 企業如何保障移動辦公的安全性?移動辦公存在的七大安-2019-11-01
- 北京深信服AC-1000-A400產品租賃購買,專業IT上網行為管理-2019-11-01
- 互聯網企業軟件開發如何才能沒有漏洞?專業工程師給出-2019-11-01
- 如何避免APP的“越權”行為?要靠制定相關法律法規-2019-11-01