# 一、实验名称 子网划分与静态(缺省)路由配置 # 二、实验目的 配置静态路由或缺省路由,实现不同网段下主机的通信。 # 三、实验内容 1、熟悉子网划分、网关设置,不同子网如何通信;(参考实验3) 2、熟悉路由器的基本配置指令;(参考实验10) 3、了解静态(缺省)路由配置的原理与配置指令;对照实验指导书中的(实验11)的要求,配置相应的静态路由或缺省路由,实现不同网段下主机的通信。 # 四、实验仪器 Cisco Packet Tracer Version:8.2.2.0400 # 五、实验原理 - **子网划分**:子网划分是将一个大的网络划分为多个较小的子网的过程。通过增加网络位的数量,可以创建更多的子网,每个子网都有自己的网络地址和广播地址。这有助于提高IP地址的使用效率,同时还可以增强网络安全性和性能。 - **静态路由配置**:静态路由是一种手动配置的路由,它指定了从源到目标的数据包传输路径。静态路由不会自动更新,需要管理员手动添加或修改。对于小型网络或者特定路由需求,静态路由提供了一种简单且直接的方式来控制数据流。 - **缺省路由(默认路由)**:缺省路由是一种特殊的静态路由,用于当没有匹配的路由时作为最后的选择。缺省路由通常指向互联网网关或其他外部网络接口,适用于不知道目的地网络的具体路由情况。 # 六、实验过程及实验结果 ## 实验 3 **(1)** 将IP地址与子网掩码进行逐位与得到子网号 - `172.16.0.220/25` 属于子网 `172.16.0.128/25`,     `172.16.2.33/25` 属于子网 `172.16.2.0/25`。 - `192.168.1.60/26` 和 `192.168.1.66/26` 不在同一个子网中,不能直接互相 Ping 通。 - `210.89.14.25/23` 和 `210.89.15.89/23` 在同一个子网中,可以互相 Ping 通;`210.89.16.148/23` 在另一个子网中,无法直接通信。 **(2)** 总共有100台左右的主机,大致等量分布在两个地点,也就是说各地大致有50台主机。每个地方分配一个有64个IP地址的子网比较合理,所以主机号需要占6位($2^6 = 64$) $32 - 6 = 26$ 位作为网络前缀,因此子网掩码为:`255.255.255.192` 两个子网分配情况如下: | 地点 | 网络地址 | 子网掩码 | 最小 IP 地址 | 最大 IP 地址 | 广播地址 | | -------- | --------------- | --------------- | ------------ | ------------- | ------------- | | **地点 1** | 192.168.1.0/26 | 255.255.255.192 | 192.168.1.1 | 192.168.1.62 | 192.168.1.63 | | **地点 2** | 192.168.1.64/26 | 255.255.255.192 | 192.168.1.65 | 192.168.1.126 | 192.168.1.127 | **(3)** 因为存在700台主机, $2^{n}-2\ge700$ 可得主机位数至少需要10位 又因为是B类网, 默认主机位数为 16 位, 所以子网位数为 $16 - 10=6$ 位. 所以子网掩码为 `255.255.252.0` 第一个子网的最小IP地址:`192.168.0.1` 第一个子网的最大IP地址:`192.168.3.254` **(4)** C类网有24为作为网络号. 需要划分28个子网, 所以需要5为子网位, 子网掩码即为 `255.255.255.248` $32 - 24 - 5 = 3$ 所以只剩下三位作为主机号. 可分配的IP地址为 $2^3=8$ 个, 再去掉一个网络地址一个广播地址, 只能给主机分配六个IP地址. ## 实验 10 **(1)路由器有多少种配置模式?** * 用户模式 `Router>` * 特权模式 `Router#` * 全局配置模式 `Router(config)#` * 接口配置模式 `Router(config-if)#` * 线路配置模式 `Router(config-line)#` * 路由配置模式 `Router(config-router)#` **(2)为了方便管理,路由器需开通telnet功能,请问如何配置路由器?** ``` Router>enable Router#configure terminal Router(config)#line vty 0 4 Router(config-line)#password cisco Router(config-line)#login Router(config-line)#exit Router(config)#enable secret class Router(config)#end Router# ``` **(3)查看路由器所有配置信息用哪条命令?** `show running-config` **(4)如果不设置路由器远程登录密码与路由器特权模式密码,可以通过telnet访问路由器吗?** 无法访问 **(5)PC1为什么不能Ping通PC0和S0/0的IP地址(172.159.1.1)?** 没有配置对应的静态路由 ## 实验 11 ### 1. 基本拓扑连接 ### 2. 路由器基本端口与IP配置 RouterA的基本配置如下 ```bash Router>en Router#conf t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#no ip domain-look Router(config)#int f0/0 Router(config-if)#ip address 192.168.1.1 255.255.255.0 Router(config-if)#no shutdown Router(config-if)# %LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up Router(config-if)#exit Router(config)#int f0/1 Router(config-if)#ip address 172.1.1.1 255.255.255.0 Router(config-if)#no shut Router(config-if)# %LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up Router(config-if)#end Router# %SYS-5-CONFIG_I: Configured from console by console ``` RouterB的基本配置如下 ```bash Router>en Router#conf t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#no ip domain-look Router(config)#int f0/0 Router(config-if)#ip address 172.2.2.1 255.255.255.0 Router(config-if)#no shut Router(config-if)# %LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up Router(config-if)#exit Router(config)#int f0/1 Router(config-if)#ip address 192.168.1.2 255.255.255.0 Router(config-if)#no shut Router(config-if)# %LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up Router(config-if)#end Router# %SYS-5-CONFIG_I: Configured from console by console Router# ``` 此时在PC0中尝试ping PC1 和 router1时终端输出如下 PC0 和 PC1 的子网掩码相同, 发往网关 `172.1.1.1` 后检查为该子网的IP地址, 返回给本网络, 所以最终能够到达 `172.1.1.3` 的PC1 ### 3. 配置route1的静态路由 配置一条静态路由,指定到达网络172.2.2.0/24的数据包应通过下一跳地址192.168.1.2转发。 ```bash Router>en Router#conf t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#ip route 172.2.2.0 255.255.255.0 192.168.1.2 Router(config)#end Router# %SYS-5-CONFIG_I: Configured from console by console Router# ``` 在router1的CLI执行以上命令之后再次尝试ping PC1 和 router2, 结果依旧如下 原因是没有配置router2的静态路由, 报文无法回传 ### 4. 配置router1静态路由 ```bash Router>en Router#conf t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#ip route 172.1.1.0 255.255.255.0 192.168.1.1 Router(config)#end Router# %SYS-5-CONFIG_I: Configured from console by console Router# ``` 在配置好router1的静态路由后, 分别在router0和router1中使用 `show ip route`命令查看路由信息, 结果如下 ![](http://IMG-HOST-REMOVED/blog-img/20250327203638274.webp) 分别在PC0和PC2上测试几台主机之间的连通性, 结果如下 ![](http://IMG-HOST-REMOVED/blog-img/20250327203908455.webp) 说明可以正常实现不同网段下主机的通信 ### 5. 在路由器上使用trace命令追踪数据包的走向 在router0上使用 `trace 172.2.2.3` CLI输出结果如下 ![](http://IMG-HOST-REMOVED/blog-img/20250327204327163.webp) 可以看到确实是由router1转发之后送到了PC2接收 ### 6. 思考题1 1. 首先给两个路由器装上串口模块 `WIC-1T` 2. 使用 `Serial DCE` 线讲router0的 `Se0/0/0` 与router1的 `Se0/0/0` 相连 3. 在router0中进行如下配置 ```bash Router>en Router#conf t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#int s0/0/0 Router(config-if)#clock rate 64000 Router(config-if)#no shutdown Router(config-if)#exit Router# Router#conf t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#int s0/0/0 Router(config-if)#ip address 192.168.1.1 255.255.255.0 Router(config-if)# Router(config-if)#exit Router(config)#ip route 172.2.2.0 255.255.255.0 192.168.1.2 Router(config)#end Router# ``` 4. 在router1中进行如下配置 ```bash Router#conf t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#int s0/0/0 Router(config-if)#ip address 192.168.1.2 255.255.255.0 Router(config-if)#no shutdown Router(config-if)# ``` 5. 分别在router0, router1中使用 `show controller s0/0/0` 查看接口配置 ![](http://IMG-HOST-REMOVED/blog-img/20250327205054173.webp) router0中的s0/0/0为DCE, router1中为DTE 6. 再次测试主机间的连通性, 发现此时不同网段下主机可以通信 ![](http://IMG-HOST-REMOVED/blog-img/20250327205333057.webp) ### 7. 思考题2 1. 在最左方添加好新的网络拓扑 2. 分配新添加网段涉及到的IP | 设备 | 接口 | IP地址 | 子网掩码 | 网关 | | -------- | ---- | -------------- | ------------- | --------- | | Router 2 | F0/0 | 192.168.2.1/24 | 255.255.255.0 | | | | F0/1 | 172.3.3.1/24 | 255.255.255.0 | | | Router 1 | F0/2 | 192.168.2.2/24 | 255.255.255.0 | | | PC4 | | 172.3.3.2/24 | 255.255.255.0 | 172.3.3.1 | | PC5 | | 172.3.3.3/24 | 255.255.255.0 | 172.3.3.1 | 3. 路由配置 在router0上进行如下配置 ```bash Router>en Router#conf t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#int f0/0 Router(config-if)#ip address 192.168.2.2 255.255.255.0 Router(config-if)#no shut Router(config-if)# %LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up Router(config-if)#exit Router(config)#ip route 172.3.3.0 255.255.255.0 192.168.2.1 Router(config)# ``` 在router2上进行如下配置 ```bash Router>en Router#conf t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#int f0/0 Router(config-if)#ip address 192.168.2.1 255.255.255.0 Router(config-if)#no shut Router(config-if)# %LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up Router(config-if)#exit Router(config)#int f0/1 Router(config-if)#ip address 172.3.3.1 255.255.255.0 Router(config-if)#no shut Router(config-if)# %LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up Router(config-if)#exit Router(config)#ip route 0.0.0.0 0.0.0.0 192.168.2.2 Router(config)# ``` 在router1上进行如下配置 ```bash Router>en Router#conf t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#ip route 172.3.3.0 255.255.255.0 192.168.1.1 Router(config)# ``` 4. 进行连通性测试 分别在不同子网的设备下尝试ping其他子网的主机, 发现均成功. 此时不同网段下主机可以通信 ![](http://IMG-HOST-REMOVED/blog-img/20250327210320159.webp) # 七、讨论与结论 在本次实验中,我们通过子网划分和静态(缺省)路由配置的实践操作,深入理解了网络通信的基本原理和技术实现。 **实验现象分析** - **成功案例**:在正确配置了路由器的接口IP地址和静态路由后,不同子网下的主机能够互相Ping通,证明了我们的配置是正确的。这表明对于小型且拓扑结构明确的网络环境,静态路由是一种有效的解决方案。 - **连通性测试结果**:通过trace命令追踪数据包的走向,我们可以清晰地看到数据包是如何从一个子网通过路由器转发到另一个子网的,这对于理解路由过程非常有帮助。 **实验故障及处理方法** - **常见故障**:在实验过程中,如果PC1无法Ping通其他子网的主机或路由器接口,通常是由于没有正确配置静态路由或者路由表中缺少必要的路由条目。 - **解决办法**:确保所有涉及的路由器都已配置相应的静态路由。例如,在本实验中,需要为RouterA和RouterB分别添加指向对方子网的静态路由。此外,还需检查各设备的接口是否已启用并配置正确的IP地址。 **实验中存在的问题** - **复杂度增加时的问题**:随着网络规模的扩大和拓扑结构的复杂化,手动配置静态路由变得越来越困难,容易出错,维护成本也会显著增加。 #### 心得体会 通过本次实验,我们不仅掌握了子网划分和静态路由配置的基础技能,更深刻体会到网络规划的重要性。。