静态路由

静态路由_第1张图片

一、    前期配置
          1.PC1:172.16.1.10 255.255.255.0 172.16.1.254
             PC2:172.16.2.20 255.255.255.0 172.16.2.254
             PC3:172.16.3.30 255.255.255.0 172.16.3.254
          2.路由器R1:F0/0 172.16.1.254 S1/0 10.7.1.1    LoopBack 0 192.168.1.254
             路由器R2:F0/0 172.16.2.254 S1/1 10.7.1.2   S1/0 10.7.2.1   
                                  LoopBack 0 192.168.2.254
             路由器R3:F0/0 172.16.3.254 S1/1 10.7. 2.2   LoopBack 0 192.168.3.254
 
二、各路由器的具體配置
        R1的配置
           Router>en
           Router#config t
           Enter configuration commands, one per line. End with CNTL/Z.
           Router(config)#hostname R1
           R1(config)#int f0/0
           R1(config-if)#ip add 172.16.1.254 255.255.255.0
           R1(config-if)#no sh
           %LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
           R1(config-if)#exit
           R1(config)#int loopback 0       ----進入loopback
                 %LINK-5-CHANGED: Interface Loopback0, changed state to up
          R1(config-if)#ip add 192.168.1.254 255.255.255.0              ----配置路由器的管理IP
          R1(config-if)#no sh
          R1(config-if)#int s1/0
          R1(config-if)#ip add 10.7.1.1 255.255.255.0
          R1(config-if)#clock rate 64000
          R1(config-if)#no sh
              %LINK-5-CHANGED: Interface Serial1/0, changed state to down
          R1(config-if)#exit
          R1(config)#ip route 192.168.3.0 255.255.255.0 10.7.1.2
          R1(config)#ip route 172.16.3.0 255.255.255.0 10.7.1.2
          R1(config)#ip route 10.7.2.0 255.255.255.0 10.7.1.2
          R1(config)#ip route 192.168.2.0 255.255.255.0 10.7.1.2              ----配置靜態路由
          R1(config)#exit
 
     R2的配置
         Router>en
         Router#config t
                Enter configuration commands, one per line. End with CNTL/Z.
         Router(config)#hostname R2
         R2(config)#int f0/0
         R2(config-if)#ip add 172.16.2.254 255.255.255.0
         R2(config-if)#no sh
                %LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
         R2(config-if)#exit    
         R2(config)#int loopback 0
               %LINK-5-CHANGED: Interface Loopback0, changed state to up
         R2(config-if)#ip add 192.168.2.254 255.255.255.0
         R2(config-if)#no sh
         R2(config-if)#exit
         R2(config)#int s1/1   
         R2(config-if)#ip add 10.7.1.2 255.255.255.0
         R2(config-if)#no sh
                 %LINK-5-CHANGED: Interface Serial1/1, changed state to up
         R2(config-if)#exit
         R2(config)#int s1/0   
         R2(config-if)#ip add 10.7.2.1 255.255.255.0
         R2(config-if)#no sh
         R2(config-if)#exit
         R2(config)#ip route 172.16.1.0 255.255.255.0 10.7.1.1
         R2(config)#ip route 192.168.1.0 255.255.255.0 10.7.1.1
         R2(config)#ip route 172.16.3.0 255.255.255.0 10.7.2.2
         R2(config)#ip route 192.168.3.0 255.255.255.0 10.7.2.2
         R2(config)#exit
 
     R3的配置
         Router>en
         Router#config t
                Enter configuration commands, one per line. End with CNTL/Z.
         Router(config)#hostname R3
         R3(config)#int f0/0
         R3(config-if)#ip add 172.16.3.254 255.255.255.0
         R3(config-if)#no sh
         R3(config-if)#exit
         R3(config)#int loopback 0
         R3(config-if)#ip add 192.168.3.254 255.255.255.0
         R3(config-if)#no sh
         R3(config-if)#exit
         R3(config)#int s1/1
         R3(config-if)#ip add 10.7.2.2 255.255.255.0
         R3(config-if)#clock rate 64000
         R3(config-if)#no sh
               %LINK-5-CHANGED: Interface Serial1/1, changed state to up
         R3(config-if)#exit
         R3(config)#ip route 192.168.1.0 255.255.255.0 10.7.2.1
         R3(config)#ip route 172.16.1.0 255.255.255.0 10.7.2.1
         R3(config)#ip route 192.168.2.0 255.255.255.0 10.7.2.1
         R3(config)#ip route 172.16.2.0 255.255.255.0 10.7.2.1
         R3(config)#ip route 10.7.1.0 255.255.255.0 10.7.2.1
         R3(config)#exit
 
三、     查看路由信息
        R1#sh 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
                    10.0.0.0/24 is subnetted, 2 subnets
                    C        10.7.1.0 is directly connected, Serial1/0
                     S        10.7.2.0 [1/0] via 10.7.1.2
                           172.16.0.0/24 is subnetted, 2 subnets
                     C        172.16.1.0 is directly connected, FastEthernet0/0
                     S        172.16.3.0 [1/0] via 10.7.1.2
                     C     192.168.1.0/24 is directly connected, Loopback0
                     S     192.168.2.0/24 [1/0] via 10.7.1.2
                     S     192.168.3.0/24 [1/0] via 10.7.1.2
 
四、     验证
            用前期配置中的IP可以互相使用PING命令进行验证,如果有IP地址无法PING 
            说明配置有问题,需要查看配置信息。
 
 
 **下面为配置静态路由的命令
ip route               
配置或删除静态路由。
[ no ] ip route ip-address { mask | mask-length } { interfacce-name | gateway-address } [ preference preference-value ] [ reject | blackhole ] 【参数说明】   
ip-address和mask为目的ip地址和掩码,点分十进制格式,由于要求掩码32位中‘1’必须是连续的,因此点分十进制格式的掩码可以用掩码长度mask-length来代替,掩码长度为掩码中连续‘1’的位数。
interfacce-name指定该路由的发送接口名,gateway-address为该路由的下一跳ip地址(点分十进制格式)。
preference-value为该路由的优先级别,范围0~255。
reject指明为不可达路由。
blackhole指明为黑洞路由。