静态路由配置综合实验报告
一、分析要求
- 划分ip地址及环回地址
- 在R5上开启DHCP协议
- R5和R6有一条线路为浮动静态路由
- 负载均衡
- 汇总路由,R5作为缺省边界路由器,设置空接口
- 写路由
二、实施步骤
1. 划分ip
- 因为每个路由器上需要有2个环回地址,根据拓扑图可以先划1个骨干链路及6个支干链路,再由此进行细分;
2. 配置接口IP并用同网段ip去ping来测试;
- 命令
[R1]int g0/0/0 //进入接口
[R1-GigabitEthernet0/0/0]ip add 192.168.1.1 30 //配置接口IP(网关IP)
[R1]int g0/0/1
[R1-GigabitEthernet0/0/1]ip add 192.168.1.5 30
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 192.168.1.2 30
[R2]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 192.168.1.9 30
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 192.168.1.6 30
[R3]int g0/0/1
[R3-GigabitEthernet0/0/1]ip add 192.168.1.13 30
[R4]int g0/0/0
[R4-GigabitEthernet0/0/0]ip add 192.168.1.10 30
[R4]int g0/0/1
[R4-GigabitEthernet0/0/1]ip add 192.168.1.14 30
[R4]int g0/0/2
[R4-GigabitEthernet0/0/2]ip add 192.168.1.17 30
[R4]int g4/0/0
[R4-GigabitEthernet4/0/0]ip add 192.168.1.21 30
[R5]int g0/0/0
[R5-GigabitEthernet0/0/0]ip add 192.168.1.18 30
[R5]int g0/0/1
[R5-GigabitEthernet0/0/1]ip add 192.168.1.22 30
[R5]int g0/0/2
[R5-GigabitEthernet0/0/2]ip add 192.168.1.193 27
测试
(例)
3. 配置环回接口;
- 命令
[R1]interface LoopBack 0 //创建接口
[R1-LoopBack0]ip add 192.168.1.33 28 //配置接口IP
[R1]interface LoopBack 1
[R1-LoopBack1]ip add 192.168.1.49 28
[R2]interface LoopBack 0
[R2-LoopBack0]ip add 192.168.1.65 28
[R2]int l 1
[R2-LoopBack1]ip add 192.168.1.81 28
[R3]int l 0
[R3-LoopBack0]ip add 192.168.1.97 28
[R3]int l 1
[R3-LoopBack1]ip add 192.168.1.113 28
[R4]int l 0
[R4-LoopBack0]ip add 192.168.1.129 28
[R4]int l 1
[R4-LoopBack1]ip add 192.168.1.145 28
[R5]int l 0
[R5-LoopBack0]ip add 192.168.1.161 28
[R5]int l 1
[R5-LoopBack1]ip add 192.168.1.177 28
4. R5配置DHCP并测试
- 命令
[R5]dhcp enable //开启DHCP服务
[R5]ip pool didi //创建池塘,名为didi
[R5-ip-pool-didi]network 192.168.1.192 mask 24 //地址池网段
[R5-ip-pool-didi]gateway-list 192.168.1.193 //网关IP
[R5-ip-pool-didi]dns-list 114.114.114.114 //DNS IP
[R5]int g0/0/2
[R5-GigabitEthernet0/0/2]dhcp select global //激活接口DHCP服务功能
测试
5. 写入骨干链路路由及环回地址路由并测试
- 将环回地址进行汇总作为一条路由,减少路由项
- 根据拓扑图分析,可以
将R4右边的路由作为缺省路由
,减少路由项,所以先不写入本步骤
[R1]ip route-static 192.168.1.8 30 192.168.1.2 //配置目的IP,,掩码,下一跳
[R1]ip route-static 192.168.1.12 30 192.168.1.6
[R1]ip route-static 192.168.1.64 27 192.168.1.2
[R1]ip route-static 192.168.1.96 27 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
[R2]ip route-static 192.168.1.4 30 192.168.1.1
[R2]ip route-static 192.168.1.12 30 192.168.1.10
[R2]ip route-static 192.168.1.32 27 192.168.1.1
[R2]ip route-static 192.168.1.128 27 192.168.1.10
[R2]ip route-static 192.168.1.96 27 192.168.1.1
[R2]ip route-static 192.168.1.96 27 192.168.1.10
[R3]ip route-static 192.168.1.0 30 192.168.1.5
[R3]ip route-static 192.168.1.8 30 192.168.1.14
[R3]ip route-static 192.168.1.32 27 192.168.1.5
[R3]ip route-static 192.168.1.128 27 192.168.1.14
[R3]ip route-static 192.168.1.64 27 192.168.1.5
[R3]ip route-static 192.168.1.64 27 192.168.1.14
[R4]ip route-static 192.168.1.0 30 192.168.1.9
[R4]ip route-static 192.168.1.4 30 192.168.1.13
[R4]ip route-static 192.168.1.64 27 192.168.1.9
[R4]ip route-static 192.168.1.96 27 192.168.1.13
[R4]ip route-static 192.168.1.32 27 192.168.1.9
[R4]ip route-static 192.168.1.32 27 192.168.1.13
[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
[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
测试
(例)
6. 配缺省路由并测试
[R1]ip route-static 0.0.0.0 0 192.168.1.2 //配置缺省IP地址及下一跳
[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
测试
(例)
7. 配置浮动静态路由并抓包测试
- 配置
[R4]ip route-static 0.0.0.0 0 192.168.1.22 preference 61 //设置优先级高于1000M链路的优先级
[R5]ip route-static 192.168.1.0 30 192.168.1.21 pre 61
[R5]ip route-static 192.168.1.4 30 192.168.1.21 pre 61
[R5]ip route-static 192.168.1.8 30 192.168.1.21 pre 61
[R5]ip route-static 192.168.1.12 30 192.168.1.21 pre 61
[R5]ip route-static 192.168.1.32 27 192.168.1.21 pre 61
[R5]ip route-static 192.168.1.64 27 192.168.1.21 pre 61
[R5]ip route-static 192.168.1.96 27 192.168.1.21 pre 61
[R5]ip route-static 192.168.1.128 27 192.168.1.21 pre 61
- 查看路由表
[R5]dis ip ro p s //查看路由表
抓包测试
- 在 R5 的 0/0/1 接口抓包
不关闭
R5的 0/0/0 接口,用R1 ping R5的环回 –无数据包
关闭
R5的 0/0/0 接口,用R1 ping R5的环回 –有数据包
- 在 R5 的 0/0/1 接口抓包
8. 配置空接口
- 当汇总地址和缺省路由同时存在,容易存在路由黑洞,形成环路,配置空接口可防此类环;
[R1]ip route-static 192.168.1.32 27 NULL 0 //汇总地址IP,路由项匹配原则是按照最长掩码 匹配原则,当这个网段没有路由黑洞时,会进行精确匹配,不会丢入空接口;
[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
[R5]ip route-static 192.168.1.160 27 NULL 0
测试
:
将 R2 的 192.168.1.64/28 环回网段删掉,用R1 ping 192.168.1.65/28,在R2的0/0/1接口抓包,。如果空接口设置不成功,这个报文会被R2以缺省路由传输出去;如果设置成功,将不会存在数据。
[R2]undo interface LoopBack 0