八 静态路由综合实验
(1)划分网段
# 192.168.1.0 24#分析:每个路由器存在两个环回接口,可以把两个环回接口分配一个环回地址,所以是四个环回,一个骨干,这样分配,不会出现路由黑洞#192.168.1.00000000 24192.168.1.000 00000 27 ---192.168.1.0 27192.168.1.001 00000 27---192.168.1.32 27192.168.1.010 00000 27---192.168.1.64 27192.168.1.011 00000 27---192.168.1.96 27192.168.1.100 00000 27---192.168.1.128 27192.168.1.101 00000 27192.168.1.110 00000 27192.168.1.111 00000 27#给每台路由器的两个环回地址分配环回地址的网络号192.168.1.32 27---192.168.1.32 28和192.168.1.48 28192.168.1.64 27---192.168.1.64 28和192.168.1.80 28192.168.1.96 27---192.168.1.96 28和192.168.1.112 28192.168.1.128 27---192.168.1.128 28和192.168.1.144 28#给一个骨干分配网段192.168.1.0 27 因为骨干需要六个网段用192.168.1.000 00000 27192.168.1.000 000 00 30---192.168.1.0 30192.168.1.000 001 00 30---192.168.1.4 30192.168.1.000 010 00 30---192.168.1.8 30192.168.1.000 011 00 30---192.168.1.12 30192.168.1.000 100 00 30---192.168.1.16 30192.168.1.000 101 00 30---192.168.1.20 30192.168.1.000 110 00 30---192.168.1.24 30192.168.1.000 111 00 30---192.168.1.28 30
(2)配置每台路由器的环回地址
[r1]int lo 0[r1-LoopBack0]ip add 192.168.1.33 28[r1-LoopBack0]int lo 1[r1-LoopBack1]ip add 192.168.1.49 28[r2]int lo 0[r2-LoopBack0]ip add 192.168.1.65 28[r2-LoopBack0]int lo 1[r2-LoopBack1]ip add 192.168.1.81 28[r3]int lo 0[r3-LoopBack0]ip add 192.168.1.97 28[r3-LoopBack0]int lo 1[r3-LoopBack1]ip add 192.168.1.113 28[r4]int lo 0[r4-LoopBack0]ip add 192.168.1.129 28[r4-LoopBack0]int lo 1[r4-LoopBack1]ip add 192.168.1.145 28[r5]int lo 0[r5-LoopBack0]ip add 5.5.5.5 24
(3)配骨干的IP地址
[r1]int g 0/0/0[r1-GigabitEthernet0/0/0]ip add 192.168.1.1 30[r1-GigabitEthernet0/0/0]int g 0/0/1[r1-GigabitEthernet0/0/1]ip add 192.168.1.5 30[r2]int g 0/0/0[r2-GigabitEthernet0/0/0]ip add 192.168.1.2 30[r2-GigabitEthernet0/0/0]int g 0/0/1[r2-GigabitEthernet0/0/1]ip add 192.168.1.9 30[r3]int g 0/0/0[r3-GigabitEthernet0/0/0]ip add 192.168.1.6 30[r3-GigabitEthernet0/0/0]int g 0/0/1[r3-GigabitEthernet0/0/1]ip add 192.168.1.13 30[r4]int g 0/0/0[r4-GigabitEthernet0/0/0]ip add 192.168.1.10 30[r4-GigabitEthernet0/0/0]int g 0/0/1[r4-GigabitEthernet0/0/1]ip add 192.168.1.14 30[r4-GigabitEthernet0/0/1]int g 0/0/2[r4-GigabitEthernet0/0/2]ip add 192.168.1.17 30[r4]int e 4/0/0[r4-Ethernet4/0/0]ip add 192.168.1.21 30[r5]int g 0/0/0[r5-GigabitEthernet0/0/0]ip add 192.168.1.18 30[r5-GigabitEthernet0/0/0]int g 0/0/1[r5-GigabitEthernet0/0/1]ip add 192.168.1.22 30
(4)写静态路由保证全网可达
[r1]ip route-static 192.168.1.64 27 192.168.1.2[r1]ip route-static 192.168.1.8 30 192.168.1.2[r1]ip route-static 192.168.1.96 27 192.168.1.6[r1]ip route-static 192.168.1.12 30 192.168.1.6[r1]ip route-static 192.168.1.128 27 192.168.1.2[r1]ip route-static 192.168.1.128 27 192.168.1.6[r1]ip route-static 192.168.1.16 30 192.168.1.6[r1]ip route-static 192.168.1.16 30 192.168.1.2[r2]ip route-static 192.168.1.32 27 192.168.1.1[r2]ip route-static 192.168.1.4 30 192.168.1.1[r2]ip route-static 192.168.1.128 27 192.168.1.10[r2]ip route-static 192.168.1.12 30 192.168.1.10[r2]ip route-static 192.168.1.16 30 192.168.1.10[r2]ip route-static 192.168.1.96 27 192.168.1.10[r2]ip route-static 192.168.1.96 27 192.168.1.1[r3]ip route-static 192.168.1.32 27 192.168.1.5 [r3]ip route-static 192.168.1.0 30 192.168.1.5[r3]ip route-static 192.168.1.128 27 192.168.1.14[r3]ip route-static 192.168.1.16 30 192.168.1.14[r3]ip route-static 192.168.1.8 30 192.168.1.14[r3]ip route-static 192.168.1.64 27 192.168.1.14[r3]ip route-static 192.168.1.64 27 192.168.1.5[r4]ip route-static 192.168.1.64 27 192.168.1.9[r4]ip route-static 192.168.1.0 30 192.168.1.9[r4]ip route-static 192.168.1.96 27 192.168.1.13[r4]ip route-static 192.168.1.4 30 192.168.1.13[r4]ip route-static 192.168.1.32 27 192.168.1.13[r4]ip route-static 192.168.1.32 27 192.168.1.9[r5]ip route-static 192.168.1.32 27 192.168.1.17[r5]ip route-static 192.168.1.64 27 192.168.1.17[r5]ip route-static 192.168.1.96 27 192.168.1.17[r5]ip route-static 192.168.1.128 27 192.168.1.17[r5]ip route-static 192.168.1.0 30 192.168.1.17[r5]ip route-static 192.168.1.4 30 192.168.1.17[r5]ip route-static 192.168.1.8 30 192.168.1.17[r5]ip route-static 192.168.1.12 30 192.168.1.17
(5)写缺省路由
[r1]ip route-static 0.0.0.0 0 192.168.1.2[r1]ip route-static 0.0.0.0 0 192.168.1.6[r2]ip route-static 0.0.0.0 0 192.168.1.10[r3]ip route-static 0.0.0.0 0 192.168.1.14[r4]ip route-static 0.0.0.0 0 192.168.1.18
利用静态路由的优先级,达到备份链路的效果。(浮动静态路由)
[r5]display this [r5]ip route-static 192.168.1.0 255.255.255.252 192.168.1.21 pr 61[r5]ip route-static 192.168.1.4 255.255.255.252 192.168.1.21 pr 61[r5]ip route-static 192.168.1.8 255.255.255.252 192.168.1.21 pr 61[r5]ip route-static 192.168.1.12 255.255.255.252 192.168.1.21 pr 61[r5]ip route-static 192.168.1.32 255.255.255.224 192.168.1.21 pr 61[r5]ip route-static 192.168.1.64 255.255.255.224 192.168.1.21 pr 61[r5]ip route-static 192.168.1.96 255.255.255.224 192.168.1.21 pr 61[r5]ip route-static 192.168.1.128 255.255.255.224 192.168.1.21 pr 61
(6)避免环路的出现
本实验由于前面IP划的好,不存在路由黑洞,假设存在被动环路,也就是R1的环回地址192.168.1.49接口断了,5.5.5.5去ping 192.168.1.49,然后通过缺省再经R1可达5.5.5.5,造成环路的出现。(R2,R3,R4同样成立)
所以,在黑洞路由器上,写一条指向汇总网段,出接口是空接口的路由信息。
[r1]ip route-static 192.168.1.32 27 NULL 0[r2]ip route-static 192.168.1.64 27 NULL 0[r3]ip route-static 192.168.1.96 27 NULL 0[r4]ip route-static 192.168.1.128 27 NULL 0