静态路由的应用场合
          一个小型到中型的网络,而且没有或只有较小的扩充计划时。
          静态路由要手工输入,手工管理;管理开销对于动态路由来说是一个大大的负担。
静态路由优缺点
          优点:
            1.对路由器CPU没有管理性开销
            2.在路由器间没有带宽占用
            3.增加安全性
          缺点:
            1.必须真正了解网络
            2.对于新添网络配置繁琐
            3.对于大型网络工作量巨大
静态路由的配置
Router(config)#ip route network  [mask] {address | interface}[distance] [permanent]
Routerconfig#ip route 目标网段 目标网段的网络掩码 直连邻居的接口IP地址
(直连邻居的接口IP地址=下一跳的IP地址=网关)
 
下面我们通过试验来验证静态路由的配置
CCNA试验我使用的是模拟器
CCNA 配置试验之一 静态路由_职场
试验环境如下:
CCNA 配置试验之一 静态路由_静态路由_02
试验环境说明:
R1ip地址为 192.168.1.1S0/0 网络掩码为255.255.255.0
R2ip地址为 192.168.1.2(S0/0)  192.168.2.1(S0/1) 网络掩码为255.255.255.0
R3ip地址为 192.168.2.2 (S0/1)  192.168.3.1S0/2) 网络掩码为255.255.255.0
R4ip地址为 192.168.3.2(S0/2) 网络掩码为255.255.255.0
R1S0/0端口、R2S0/1端口、R3S0/2端口为DCE
试验要求:
要求在路由器间配置静态路由使路由器间相互ping通。实现全网全通。
好了,开始工作
R1
en
conf  t
host r1                                    定义路由器名称
CCNA 配置试验之一 静态路由_职场_03
enable password cisco                        定义特权口令
CCNA 配置试验之一 静态路由_休闲_04
line vty 0 4                                 定义telne口令
pass cisco      
login
CCNA 配置试验之一 静态路由_CCNA_05
exit
int s0/0                                     定义接口信息
ip addr 192.168.1.1 255.255.255.0
clock rate 64000                              设置时钟频率
no shut
CCNA 配置试验之一 静态路由_CCNA_06
exit 
ip route 192.168.2.0 255.255.255.0 192.168.1.2     R1中配置静态路由
ip route 192.168.3.0 255.255.255.0 192.168.1.2
CCNA 配置试验之一 静态路由_职场_07
 
 
R2
en
conf  t
host r2                                    定义路由器名称
CCNA 配置试验之一 静态路由_静态路由_08
enable password cisco                        定义特权口令
CCNA 配置试验之一 静态路由_静态路由_09
line vty 0 4                                 定义telne口令
pass cisco      
login
CCNA 配置试验之一 静态路由_静态路由_10
exit
int s0/0                                     定义接口信息
ip addr 192.168.1.2 255.255.255.0
no shut
exit
int s0/1
ip addr 192.168.2.1 255.255.255.0
clock rate 64000                              设置时钟频率
no shut
CCNA 配置试验之一 静态路由_CCNA_11
exit 
ip route 192.168.3.0 255.255.255.0 192.168.2.2     R2中配置静态路由
CCNA 配置试验之一 静态路由_CCNA_12
 
 
R3
en
conf  t
host r3                                    定义路由器名称
CCNA 配置试验之一 静态路由_CCNA_13
enable password cisco                        定义特权口令
CCNA 配置试验之一 静态路由_休闲_14
line vty 0 4                                 定义telne口令
pass cisco      
login
CCNA 配置试验之一 静态路由_职场_15
exit
int s0/1                                     定义接口信息
ip addr 192.168.2.2 255.255.255.0
no shut
exit
int s0/2
ip addr 192.168.3.1 255.255.255.0
clock rate 64000                              设置时钟频率
no shut
CCNA 配置试验之一 静态路由_休闲_16
exit 
ip route 192.168.1.0 255.255.255.0 192.168.2.1     R3中配置静态路由
CCNA 配置试验之一 静态路由_休闲_17
 
R4
 
en
conf  t
host r4                                    定义路由器名称
CCNA 配置试验之一 静态路由_职场_18
enable password cisco                        定义特权口令
CCNA 配置试验之一 静态路由_休闲_19
line vty 0 4                                 定义telne口令
pass cisco      
login
CCNA 配置试验之一 静态路由_静态路由_20
exit
int s0/2                                     定义接口信息
ip addr 192.168.3.2 255.255.255.0
no shut
CCNA 配置试验之一 静态路由_休闲_21
exit
ip route 192.168.1.0 255.255.255.0 192.168.3.1     R4中配置静态路由
ip route 192.168.2.0 255.255.255.0 192.168.3.1
CCNA 配置试验之一 静态路由_休闲_22
R1ping R2 R3 R4  如下图所示,全网全通啦
CCNA 配置试验之一 静态路由_休闲_23
 
如下是在路由器R1  R2  R3  R4 里做出的配置 红色字体为配置内容
R1
Router>en
Router#conf  t
Enter configuration commands, .e per line.  End with CNTL/Z.
Router(config)#host r1
r1(config)#enable password cisco
r1(config)#line vty 0 4
r1(config-line)#pass cisco
r1(config-line)#login
r1(config-line)#exit
r1(config)#int s0/0
r1(config-if)#ip addr 192.168.1.1 255.255.255.0
r1(config-if)#clock rate 64000
r1(config-if)#no shut
r1(config-if)#exit
*Mar  1 00:05:14.311: %LINK-3-UPDOWN: Interface Serial0/0, changed state to up
*Mar  1 00:05:15.311: %LINEPROTO-5-UPDOWN: Line protocol . Interface Serial0/0,
 changed state to up
r1(config)#ip route 192.168.2.0 255.255.255.0 192.168.1.2
r1(config)#
*Mar  1 00:05:43.055: %LINEPROTO-5-UPDOWN: Line protocol . Interface Serial0/0,
 changed state to down
r1(config)#ip route 192.168.3.0 255.255.255.0 192.168.1.2
 
R2
 
Router>en
Router#conf t
Enter configuration commands, .e per line.  End with CNTL/Z.
Router(config)#host r2
r2(config)#enable password cisco
r2(config)#line vty 0 4
r2(config-line)#pass cisco
r2(config-line)#login
r2(config-line)#exit
r2(config)#int s0/0
r2(config-if)#ip addr 192.168.1.2 255.255.255.0
r2(config-if)#no shut
r2(config-if)#
*Mar  1 00:05:21.035: %LINK-3-UPDOWN: Interface Serial0/0, changed state to up
*Mar  1 00:05:22.035: %LINEPROTO-5-UPDOWN: Line protocol . Interface Serial0/0,
 changed state to upexit
r2(config)#int s0/1
r2(config-if)#ip addr 192.168.2.1 255.255.255.0
r2(config-if)#clock rate 64000
r2(config-if)#no shut
r2(config-if)#exit
r2(config)#
*Mar  1 00:25:35.283: %LINEPROTO-5-UPDOWN: Line protocol . Interface Serial0/1,
 changed state to down%LINEPROTO-5-UPDOWN: Line protocol . Interface Serial0/1,
*Mar  1 00:25:45.267: %LINEPROTO-5-UPDOWN: Line protocol . Interface Serial0/1,
 changed state to up: %LINEPROTO-5-UPDOWN: Line protocol . Interface Serial0/1,
 changed state to down
r2(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2
 
 
R3 
 
Router>en
Router#conf t
Enter configuration commands, .e per line.  End with CNTL/Z.
Router(config)#host r3
r3(config)#enable password cisco
r3(config)#line vty 0 4
r3(config-line)#password cisco
r3(config-line)#login
r3(config-line)#exit
r3(config)#int s0/1
r3(config-if)#ip addr 192.168.2.2 255.255.255.0
r3(config-if)#no shut
r3(config-if)#exit
r3(config)#
*Mar  1 00:03:39.899: %LINK-3-UPDOWN: Interface Serial0/1, changed state to upi
*Mar  1 00:03:40.903: %LINEPROTO-5-UPDOWN: Line protocol . Interface Serial0/1,
 changed state to u
r3(config)#int s0/2
r3(config-if)#ip addr 192.168.3.1 255.255.255.0
r3(config-if)#clock rate 64000
r3(config-if)#no shut
r3(config-if)#
*Mar  1 00:04:24.839: %LINK-3-UPDOWN: Interface Serial0/2, changed state to up
*Mar  1 00:04:25.839: %LINEPROTO-5-UPDOWN: Line protocol . Interface Serial0/2,
 changed state to up
*Mar  1 00:04:53.839: %LINEPROTO-5-UPDOWN: Line protocol . Interface Serial0/2,
 changed state to down
r3(config-if)#exit
r3(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1
 
 
.
R4
 
Router>en
Router#conf t
Enter configuration commands, .e per line.  End with CNTL/Z.
Router(config)#host r4
r4(config)#enable pass cisco
r4(config)#line vty 0 4
r4(config-line)#pass cisco
r4(config-line)#login
r4(config-line)#exit
r4(config)#int s0/2
r4(config-if)#ip addr 192.168.3.2 255.255.255.0
r4(config-if)#no shut
r4(config-if)#
*Mar  1 00:03:04.871: %LINK-3-UPDOWN: Interface Serial0/2, changed state to up
*Mar  1 00:03:05.871: %LINEPROTO-5-UPDOWN: Line protocol . Interface Serial0/2,
 changed state to up
r4(config-if)#exit
r4(config)#ip route 192.168.1.0 255.255.255.0 192.168.3.1
r4(config)#ip route 192.168.2.0 255.255.255.0 192.168.3.1
 
下面是在R1上分别ping R2  R3  R4 的结果,
 
r1>ping 192.168.1.2
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 52/298/540 ms
r1>ping 192.168.2.1
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 140/218/376 ms
r1>ping 192.168.2.2
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 304/447/644 ms
r1>ping 192.168.3.1
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.3.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 140/460/804 ms
r1>ping 192.168.3.2
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.3.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 664/739/936 ms
哈哈 全网全通了!试验宣告成功!!!!!
 
附:静态路由的删除:
(config)#no ip route 目标网段 目标网段的网络掩码 直连邻居的接口IP地址