anonym0us 发表于 2016-03-27 17:19

静态路由

本帖最后由 anonym0us 于 2016-03-27 17:23 编辑

静态路由:


首先配置R1 R2 R3的基本配置,为相应的接口配置合理的IP 地址。同一根网线上连接的两个路由器,要配置相同的网络位,不同的主机位因为他们是位于同一个网络的不同设备。
R1配置:

Router>enable
Router#configure terminal

Router(config)#line console 0
Router(config-line)#exec-timeout0 0
Router(config-line)#logging synchronous
Router(config-line)#exit

Router(config)#no ip domain-lookup
Router(config)#ho R1



R1(config)#interface loopback 0
R1(config-if)#ip address 1.1.1.1 255.255.255.255
R1(config-if)#no shutdown
R1(config-if)#exit

R1(config)#interface loopback 1
R1(config-if)#ip address 1.1.2.1 255.255.255.255
R1(config-if)#no shutdown
R1(config-if)#exit

R1(config)#interface loopback 2
R1(config-if)#ip address 1.1.3.1 255.255.255.255
R1(config-if)#no shutdown
R1(config-if)#exit

R1(config)#interface loopback 3
R1(config-if)#ip address 1.1.4.1 255.255.255.255
R1(config-if)#no shutdown
R1(config-if)#exit

R1(config)#interface f0/0
R1(config-if)#ip address 12.1.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#exit

R2配置:

Router>enable
Router#config terminal
Router(config)#line console 0
Router(config-line)#exec-timeout 0 0
Router(config-line)#logging synchronous
Router(config-line)#exit

Router(config)#no ip domain-lookup
Router(config)#ho R2

R2(config)#interface f0/0
R2(config-if)#ip address 12.1.1.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#exit



R2(config)#interface f0/1
R2(config-if)#ip address 23.1.1.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#exit

R2(config)#interface loopback 0
R2(config-if)#ip address 2.2.2.2 255.255.255.255
R2(config-if)#noshutdown
R2(config-if)#exit

R3配置:
Router>enable
Router#config terminal

Router(config)#line console 0
Router(config-line)#exec-timeout 0 0
Router(config-line)#logging synchronous
Router(config-line)#exit
Router(config)#no ip domain-lookup

Router(config)#ho R3

R3(config)#interface f0/1
R3(config-if)#ip address 23.1.1.3 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#exit

R3(config)#interface lo0
R3(config-if)#ip address 3.3.3.3 255.255.255.255
R3(config-if)#no shutdown
R3(config-if)#exit

接下来在R1 R2 R3上配置静态路由,由于一个路由器的接口配置了IP 地址之后,对于路由器而言,就产生了到达该网络的路径,就是我们所说的直连路径。因此我们仅仅需要配置到达网络中其他地方(非直连)网络的路径即可。

R1配置:
对于R1而言直连路经就是路由表中打C 标记的路由,而2.2.2.2/32,3.3.3.3/32,23.1.1.0/24
这几条路径R1的路由表中没有(这些是非直连路径),因此需要针对这几条路径进行配置.

R1#sho 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

   1.0.0.0/32 is subnetted, 4 subnets
C       1.1.1.1 is directly connected, Loopback0
C       1.1.2.1 is directly connected, Loopback1
C       1.1.3.1 is directly connected, Loopback2
C       1.1.4.1 is directly connected, Loopback3
   12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, FastEthernet0/0
R1#
要去哪里----目标IP地址和掩码
R1(config)#ip route 3.3.3.3 255.255.255.255 12.1.1.2               有谁帮我把数据转发到目的地---下一跳地址
R1(config)#ip route 23.1.1.0 255.255.255.0 12.1.1.2
R1(config)#ip route 2.2.2.2 255.255.255.255 f0/0                   要去那里,该从那个接口把数据发出去—出接口

R2配置:
对于R2而言 只有 1.1.1.1-----1.1.2.1----1.1.3.1----1.1.4.1以及3.3.3.3 是不直接相连的(非直连),因此只需要针对这些网段写静态路由就可以了,对于1.1.1.1----1.1.4.1的这四条路径,可以用汇总的方式,以一条命令去完成对于四条命令的匹配.---进行汇总.同时注意,汇总的时候,有可能将1.1.5.1等等不存在的网段也汇总进去了,因此注意,在R1上(应为汇总的1.1.1.1—1.1.4.1 是R1上的路径)部署黑洞路由.

R2(config)#ip route 1.1.0.0 255.255.248.0 12.1.1.1
R2(config)#ip route 3.3.3.3 255.255.255.255 23.1.1.3

R1配置:

R1(config)#ip route 1.1.0.0 255.255.248.0 null 0


R3配置:
在R3上 我们可以认为R3上网络的终点,因此对于R3而言,到网络的任意一点,都可以被缺省路由匹配.

R3(config)#ip route 0.0.0.0 0.0.0.0 23.1.1.2

检查路由表,看看路径是否都齐全.
R1 R2 R3要有到达 1.1.1.1—1.1.2.1---1.1.3.1---1.1.4.1以及12.1.1.0/24;23.1.1.0/24;
2.2.2.2/32;3.3.3.3/32的路径.

R1配置:
R1#sho 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

   1.0.0.0/8 is variably subnetted, 5 subnets, 2 masks
S       1.1.0.0/21 is directly connected, Null0
C       1.1.1.1/32 is directly connected, Loopback0
C       1.1.2.1/32 is directly connected, Loopback1
C       1.1.3.1/32 is directly connected, Loopback2
C       1.1.4.1/32 is directly connected, Loopback3
   2.0.0.0/32 is subnetted, 1 subnets
S       2.2.2.2 is directly connected, FastEthernet0/0
   3.0.0.0/32 is subnetted, 1 subnets
S       3.3.3.3 via 12.1.1.2
   12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, FastEthernet0/0
   23.0.0.0/24 is subnetted, 1 subnets
S       23.1.1.0 via 12.1.1.2

R2配置:
R2#sho 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

   1.0.0.0/21 is subnetted, 1 subnets
S       1.1.0.0 via 12.1.1.1
   2.0.0.0/32 is subnetted, 1 subnets
C       2.2.2.2 is directly connected, Loopback0
   3.0.0.0/32 is subnetted, 1 subnets
S       3.3.3.3 via 23.1.1.3
   12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, FastEthernet0/0
   23.0.0.0/24 is subnetted, 1 subnets
C       23.1.1.0 is directly connected, FastEthernet0/1

R3配置:
R3#sho ip rou
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 23.1.1.2 to network 0.0.0.0

   3.0.0.0/32 is subnetted, 1 subnets
C       3.3.3.3 is directly connected, Loopback0
   23.0.0.0/24 is subnetted, 1 subnets
C       23.1.1.0 is directly connected, FastEthernet0/1
S*   0.0.0.0/0 via 23.1.1.2

丘比特全套 发表于 2016-04-01 14:28

路过~~~~~·
页: [1]
查看完整版本: 静态路由