Cisco基礎【路由器】靜態路由與默認路由


wKioL1RvTDSDytebAAD8LRfYGwo624.jpg

實現PC1 與 PC2 的通信

R1

Router>enable
Router#
Router#conf t
Router(config)#inter f 0/0
Router(config-if)#ip address 192.168.10.254 255.255.255.0
Router(config-if)#no shut
Router(config-if)#exit
Router(config)#
Router(config)#inter s 0/0/0
Router(config-if)#ip address 192.168.1.1 255.255.255.0
Router(config-if)#clock rate 64000
Router(config-if)#no shut
Router(config-if)#exit\
etected at '^' marker.
Router(config-if)#exit
Router(config)#
Router#
Router#show ip route
Codes: C - connected, S - static, I - IGRP, 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, E - EGP
       i - IS-IS, 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
 
Gateway of last resort is not set
                     //兩條直連路由
C    192.168.1.0/24 is directly connected, Serial0/0/0
C    192.168.10.0/24 is directly connected, FastEthernet0/0
Router#

R2:

Router>enable
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#inter f 0/0 
Router(config-if)#ip address 192.168.20.254 255.255.255.0
Router(config-if)#no shut
Router(config-if)#exit
Router(config)#
Router(config)#inter s 0/0/0
Router(config-if)#ip address 192.168.1.2 255.255.255.0
Router(config-if)#no shut
 
Router(config-if)#
Router(config-if)#exit
Router(config)#end
Router#
Router#show ip route
Codes: C - connected, S - static, I - IGRP, 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, E - EGP
       i - IS-IS, 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
 
Gateway of last resort is not set
                             //兩條直連路由
C    192.168.1.0/24 is directly connected, Serial0/0/0
C    192.168.20.0/24 is directly connected, FastEthernet0/0
Router#

PC 1 ping PC 2 

wKiom1RvS7qBvye0AAEZv9iCzhI680.jpg

Ping不通,目標主機不可達。路由器無法將192.168.10.0的數據包傳送出去。

配置靜態路由

R 1:

Router#conf t
  //配置靜態路由,格式爲: ip route 目的網段 子網掩碼 嚇一跳地址
Router(config)#ip route 192.168.20.0 255.255.255.0 192.168.1.2
Router(config)#exit
Router#
%SYS-5-CONFIG_I: Configured from console by console
 
Router#show ip route
Codes: C - connected, S - static, I - IGRP, 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, E - EGP
       i - IS-IS, 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
 
Gateway of last resort is not set
 
C    192.168.1.0/24 is directly connected, Serial0/0/0
C    192.168.10.0/24 is directly connected, FastEthernet0/0
S    192.168.20.0/24 [1/0] via 192.168.1.2      //出現去往192.168.20.0的網絡
Router#


R2:


Router(config)#
Router(config)#ip route 192.168.10.0 255.255.255.0 192.168.1.1
Router(config)#end
Router#
%SYS-5-CONFIG_I: Configured from console by console
 
Router#show ip route
Codes: C - connected, S - static, I - IGRP, 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, E - EGP
       i - IS-IS, 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
 
Gateway of last resort is not set
 
C    192.168.1.0/24 is directly connected, Serial0/0/0 
S    192.168.10.0/24 [1/0] via 192.168.1.1   //有去往192.168.10.0的網絡了
C    192.168.20.0/24 is directly connected, FastEthernet0/0
Router#

PC1 ping PC 2

wKioL1RvTDSTXoRYAAEXwmNflN8824.jpg

PC 2 ping PC1

wKiom1RvS7rj0ekqAAERr05d1pc075.jpg


本文出自 “趙玉強的博客” 博客,請務必保留此出處http://zhaoyuqiang.blog.51cto.com/6328846/1581089

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章