码迷,mamicode.com
首页 > 其他好文 > 详细

静态路由的配置

时间:2014-11-22 02:04:58      阅读:262      评论:0      收藏:0      [点我收藏+]

标签:静态路由 路由器 cisco


bubuko.com,布布扣

实现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)#exitetected 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 

bubuko.com,布布扣

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

bubuko.com,布布扣

PC 2 ping PC1

bubuko.com,布布扣


本文出自 “赵玉强的博客” 博客,请务必保留此出处http://zhaoyuqiang.blog.51cto.com/6328846/1581089

静态路由的配置

标签:静态路由 路由器 cisco

原文地址:http://zhaoyuqiang.blog.51cto.com/6328846/1581089

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!