From 787d504f0d55b2fd69cc71ba3cce120899f3ef14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9D=92=E7=AB=B9?= Date: Thu, 7 May 2026 19:42:42 +0800 Subject: [PATCH 1/2] a --- ...45\220\214VLAN\344\272\222\350\256\277.md" | 302 ++++++++++++++++++ 1 file changed, 302 insertions(+) create mode 100644 "15 \351\273\204\346\265\267\351\221\253/20260507 \345\215\225\350\207\202\350\267\257\347\224\261\345\256\236\347\216\260\344\270\215\345\220\214VLAN\344\272\222\350\256\277.md" diff --git "a/15 \351\273\204\346\265\267\351\221\253/20260507 \345\215\225\350\207\202\350\267\257\347\224\261\345\256\236\347\216\260\344\270\215\345\220\214VLAN\344\272\222\350\256\277.md" "b/15 \351\273\204\346\265\267\351\221\253/20260507 \345\215\225\350\207\202\350\267\257\347\224\261\345\256\236\347\216\260\344\270\215\345\220\214VLAN\344\272\222\350\256\277.md" new file mode 100644 index 00000000..109780b8 --- /dev/null +++ "b/15 \351\273\204\346\265\267\351\221\253/20260507 \345\215\225\350\207\202\350\267\257\347\224\261\345\256\236\347\216\260\344\270\215\345\220\214VLAN\344\272\222\350\256\277.md" @@ -0,0 +1,302 @@ +# 路由器vlan间路由之单臂路由 + +## 一、实验目的:  + +- 掌握单臂路由的配置方法 + +- 实现不同VLAN之间互相通信 + +- 深入理解VLAN通信原理及路由子接口 + +## 二、实验背景: + +- 公司的技术部和销售部、人力部分处于不同的办公室,三个部门的PC分处于不同的VLAN,现由于业务需求,需要使三个部门的主机能够相互访问,获得相应的资源,三个部门通过一台交换机连接一台路由器使用。 + +## 三、技术原理: + +- VLAN能有效分割局域网,实现各网络区域之间的访问控制。但现实中,往往需要配置某些VLAN之间的互联互通。而实现不同VLAN间相互通信,必须利用路由选择功能来实现,一般有两种方式:三层交换和单臂路由。 + +- 单臂路由:指在路由器的一个接口上通过配置子接口(一种“逻辑接口")的方式,以作为VLAN的网关,实现原来相互隔离的不同VLAN(虚拟局域网)之间的互联互通。 + +- VLAN间互访的原理:在接入路由器的一个物理端口上启用多个子接口,即一个物理接口划分为多个逻辑接口,每一个子接口与各个Vlan一一对应充当其网关,通过直连路由实现VLAN间相互访问。 + +- 与三层交换的方式相比,其通过软件实现交换,转发效率没有三层交换机高,且只能通过一条物理链路实现路由,无法跨端口通信,不具有可拓展性,随着网络拓扑增大,容易出现性能瓶颈,不适用于中、大型局域网。 + +- dot1q 封装协议:即IEEE 802.1Q 标准(的英文缩写),是为防止中继端口(Trunk)上承载的不同VLAN相互混乱而设计的一种VLAN封装方式,其定义了 VLAN网桥操作,从而允许在桥接局域网结构中实现定义、运行以及管理 VLAN 拓朴结构等操作。 + +- 子接口配置模式             Router(config-subif)# + +实验设备:1941Router 1台;Switch_2960 1台;PC 3台;直通线、交叉线若干。 + +## 四、实验拓扑: + +![image-20260507113113928](https://gitee.com/onesheet/picture-warehouse/raw/master/pic/upgit_20260507_1778124674.png) + + + +实验设备:1941路由器1台、2960交换机1台、pc3台 + +## 五、实验步骤: + +- 新建Cisco PT 拓扑图 + +- 为各PC设置IP及网关地址,其中网关地址分别为路由器的子接口的IP地址 + +- 在二层交换机上,分别将PC0和PC1、PC2所接端口划入vlan 10、vlan 20、vlan 30 + +- 当交换机设置两个Vlan时,逻辑上己经成为两个网络,广播被隔离了。两个Vlan的网络要通信,必须通过路由器,如果接入路由器的一个物理端口,则必须有两个子接口分别与两个Vlan对应,同时还要求与路由器相连的交换机的端口模式为trunk + +- 计算机的网关分别指向路由器的子接口 + +- 检查PC与Router所连端口的类型、模块号及端口号,并为该端口配置IP地址及子网掩码 + +- 确保与PC的IP地址在同一个子网,同时开启Router端口(默认关闭) + +- 配置子接口,开启路由器物理接口 + +- 默认封装dot1Q协议 + +- 配置路由器子接口IP地址 + + + +### 1.PC设置 + +![image-20260507103214680](https://gitee.com/onesheet/picture-warehouse/raw/master/pic/upgit_20260507_1778121137.png) + +``` +如按拓扑图 +``` + +### 2.二层交换机配置 + +步骤1:划分三个VLAN + +```bash +Switch>en +Switch#conf t +Enter configuration commands, one per line. End with CNTL/Z. +# 创建VLAN 10 20 30 +Switch(config)#vlan 10 +Switch(config-vlan)#vlan 20 +Switch(config-vlan)#vlan 30 +Switch(config-vlan)#end +Switch# +%SYS-5-CONFIG_I: Configured from console by console +# 查看VLAN的配置情况 +Switch#show vlan brief + +VLAN Name Status Ports +---- -------------------------------- --------- ------------------------------- +1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4 + Fa0/5, Fa0/6, Fa0/7, Fa0/8 + Fa0/9, Fa0/10, Fa0/11, Fa0/12 + Fa0/13, Fa0/14, Fa0/15, Fa0/16 + Fa0/17, Fa0/18, Fa0/19, Fa0/20 + Fa0/21, Fa0/22, Fa0/23, Fa0/24 + Gig0/1, Gig0/2 +10 VLAN0010 active +20 VLAN0020 active +30 VLAN0030 active +1002 fddi-default active +1003 token-ring-default active +1004 fddinet-default active +1005 trnet-default active +Switch# +``` + +![image-20260507105419546](https://gitee.com/onesheet/picture-warehouse/raw/master/pic/upgit_20260507_1778122462.png) + +如图所示,可见三个VLAN已建立好。 + +步骤2 ,将连接PC的端口划入对应的VLAN中 + +```bash +Switch#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Switch(config)#inter f0/1 //选择F0/1端口 +Switch(config-if)#switchport mode access //设置端口模式为Access +Switch(config-if)#switchport access vlan 10 //将该端口划入VLAN10 +Switch(config-if)#ex +Switch(config)#interface f0/2 +Switch(config-if)#switchport mode access +Switch(config-if)#switchport access vlan 20 +Switch(config-if)#ex +Switch(config)#interface f0/3 +Switch(config-if)#switchport mode access +Switch(config-if)#switchport access vlan 30 +Switch(config-if)#ex +Switch(config)#interface g0/1 +Switch(config-if)#switchport mode trunk //设置端口模式为TRUNK模式 +Switch(config-if)#end +Switch# +%SYS-5-CONFIG_I: Configured from console by console + +# 再次查看VLAN信息 +Switch#show vlan brief + +VLAN Name Status Ports +---- -------------------------------- --------- ------------------------------- +1 default active Fa0/4, Fa0/5, Fa0/6, Fa0/7 + Fa0/8, Fa0/9, Fa0/10, Fa0/11 + Fa0/12, Fa0/13, Fa0/14, Fa0/15 + Fa0/16, Fa0/17, Fa0/18, Fa0/19 + Fa0/20, Fa0/21, Fa0/22, Fa0/23 + Fa0/24, Gig0/1, Gig0/2 +10 VLAN0010 active Fa0/1 +20 VLAN0020 active Fa0/2 +30 VLAN0030 active Fa0/3 +1002 fddi-default active +1003 token-ring-default active +1004 fddinet-default active +1005 trnet-default active +Switch# +``` + +![image-20260507110509602](https://gitee.com/onesheet/picture-warehouse/raw/master/pic/upgit_20260507_1778123109.png) + + + +### 3.路由器配置 + +步骤1: + +```bash +Router>en +Router#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Router(config)#interface g0/1 +Router(config-if)#no shutdown // 开启端口 + +Router(config-if)# +%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up + +%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up + +Router(config-if)#exit +Router(config)#interface g0/1.1 //进入路由器第0模块第1端口第1子接口 +Router(config-subif)# +%LINK-5-CHANGED: Interface GigabitEthernet0/1.1, changed state to up + +%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1.1, changed state to up + +Router(config-subif)#encapsulation dot1Q 10 //封装协议为dot1Q允许通过的VLAN为10 +Router(config-subif)#ip address 192.168.10.254 255.255.255.0 // 给这个子接口配置IP和子网掩码,用来当VLAN10的网关 +Router(config-subif)#exit +Router(config)#interface g0/1.2 //进入路由器第0模块第1端口第2子接口 +Router(config-subif)# +%LINK-5-CHANGED: Interface GigabitEthernet0/1.2, changed state to up + +%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1.2, changed state to up + +Router(config-subif)#encapsulation dot1Q 20 //封装协议为dot1Q允许通过的VLAN为20 +Router(config-subif)#ip address 192.168.20.254 255.255.255.0 +Router(config-subif)#exit +Router(config)#interface g0/1.3 //进入路由器第0模块第1端口第3子接口 +Router(config-subif)# +%LINK-5-CHANGED: Interface GigabitEthernet0/1.3, changed state to up + +%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1.3, changed state to up + +Router(config-subif)#encapsulation dot1Q 30 //封装协议为dot1Q允许通过的VLAN为30 +Router(config-subif)#ip address 192.168.30.254 255.255.255.0 +Router(config-subif)#end // end 直接返回特权模式。why? 查询一般在特权模式 +Router# +%SYS-5-CONFIG_I: Configured from console by console + +# 查看路由配置(路由表信息) +Router#show ip route +Codes: L - local, C - connected, S - static, 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 + + 192.168.10.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.10.0/24 is directly connected, GigabitEthernet0/1.1 +L 192.168.10.254/32 is directly connected, GigabitEthernet0/1.1 + 192.168.20.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.20.0/24 is directly connected, GigabitEthernet0/1.2 +L 192.168.20.254/32 is directly connected, GigabitEthernet0/1.2 + 192.168.30.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.30.0/24 is directly connected, GigabitEthernet0/1.3 +L 192.168.30.254/32 is directly connected, GigabitEthernet0/1.3 +``` + +![image-20260507112545755](https://gitee.com/onesheet/picture-warehouse/raw/master/pic/upgit_20260507_1778124346.png) + + + +### 4.测试 + +```bash +# 链路测试 +PC0(命令提示符CMD下) +ping 192.168.20.1 //链路通 +ping 192.168.30.1 //链路通 + +PC1(命令提示符CMD下) +ping 192.168.10.1 //链路通 +``` + +# 作业 + +### 1.拓扑图 + +![image-20260507193832701](https://gitee.com/wddaddds/qingzhu-picture-warehouse/raw/master/pic/upgit_20260507_1778153912.png) + +### 2.代码 + +#### 路由器 + +```bash +Router>ena +Router#conf +Router(config)#int g0/1 +Router(config-if)#no shut +Router(config-if)#exit +Router(config)#int g0/1.1 +Router(config-subif)#enc dot 10 +Router(config-subif)#ip add 192.168.10.254 255.255.255.0 +Router(config-subif)#no shut +Router(config-subif)#exit +Router(config)#int g0/1.2 +Router(config-subif)#enc dot 20 +Router(config-subif)#ip add 192.168.20.254 255.255.255.0 +Router(config-subif)#no shut +Router(config-subif)#int g0/1.3 +Router(config-subif)#enc dot 30 +Router(config-subif)#ip add 192.168.30.254 255.255.255.0 +``` + +#### 交换机 + +```bash +Switch>ena +Switch#conf +Switch(config)#vlan 10 +Switch(config-vlan)#exit +Switch(config)#vlan 20 +Switch(config-vlan)#exit +Switch(config)#vlan 30 +Switch(config-vlan)#exit +Switch(config)#int f0/1 +Switch(config-if)#swi mo acc +Switch(config-if)#swi acc vlan 10 +Switch(config-if)#exit +Switch(config)#int f0/2 +Switch(config-if)#swi mo acc +Switch(config-if)#swi acc vlan 20 +Switch(config-if)#exit +Switch(config)#int f0/3 +Switch(config-if)#swi mo acc +Switch(config-if)#swi acc vlan 30 +Switch(config-if)#exit +Switch(config)#int g0/1 +Switch(config-if)#swi mo tr +``` + -- Gitee From 12956811f9c895294e5383a6ea3cc09a6d8d3e1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9D=92=E7=AB=B9?= Date: Sat, 9 May 2026 16:27:39 +0800 Subject: [PATCH 2/2] 1 --- ...50\347\275\221\344\272\222\350\256\277.md" | 661 ++++++++++++++++++ 1 file changed, 661 insertions(+) create mode 100644 "15 \351\273\204\346\265\267\351\221\253/20260509 \351\235\231\346\200\201\350\267\257\347\224\261\345\256\236\347\216\260\345\205\250\347\275\221\344\272\222\350\256\277.md" diff --git "a/15 \351\273\204\346\265\267\351\221\253/20260509 \351\235\231\346\200\201\350\267\257\347\224\261\345\256\236\347\216\260\345\205\250\347\275\221\344\272\222\350\256\277.md" "b/15 \351\273\204\346\265\267\351\221\253/20260509 \351\235\231\346\200\201\350\267\257\347\224\261\345\256\236\347\216\260\345\205\250\347\275\221\344\272\222\350\256\277.md" new file mode 100644 index 00000000..1947f9ee --- /dev/null +++ "b/15 \351\273\204\346\265\267\351\221\253/20260509 \351\235\231\346\200\201\350\267\257\347\224\261\345\256\236\347\216\260\345\205\250\347\275\221\344\272\222\350\256\277.md" @@ -0,0 +1,661 @@ +------ + +## 一、实验目的:  + +- 掌握静态路由的配置方法和应用 + +- 掌握路由选择表中的路由描述 + +- 熟悉路由选择和分组转发的原理及过程 + +## 二、实验背景: + +- 某公司除总部外,另有一处分部,并且都有一个独立的局域网,为了使公司各部之间能相互通信,共享资源。每个出口利用一台路由器进行连接,两台路由器间公司申请了一条DDN专线(数字数据网)进行相连,要求做适当配置实现相互访问。 + +## 三、技术原理: + +- 路由器属于网络层设备,能够根据IP数据报的首部信息,选择一条最佳路径(这一过程称为"路由选择"),将数据报转发到下一跳路由地址,并最终传送到目的结点(这一过程称为"分组转发"),从而实现不同局域网(或逻辑子网)的主机之间的互相访问。 + +- 路由器是根据路由表进行选路和转发的。而路由表里就是由一条条路由信息组成。不同厂商路由器生成的路由表结构及内容可能有所差异,内容主要包括:路由源码(路由选择方式)、目的网络及其掩码、下一跳路由地址或端口、默认路由等信息。 + +- 生成路由表主要有两种方法:手工配置和动态配置,即静态路由协议配置和动态路由协议配置。 + + - 静态路由:由网络管理员手工配置固定的路由信息。具有简单、高效、可靠以及安全保密性高等优点。 + + - 动态路由:路由器利用动态路由协议(如RIP、OSPF等)自动建立路由表,并能根据实际网络拓扑结构的变化适时更新,无需管理员手工维护,适用于网络规模大、拓扑复杂的网络。 + +- 缺省/默认路由:静态路由的一种特殊情况。当数据包在査找路由表时,没有找到和目标相匹配的路由表项时,若没有配置默认路由,即指定路由器默认的下一跳地址,则路由器会将该数据包丢弃。 + + ![](https://gitee.com/onesheet/picture-warehouse/raw/master/pic/upgit_20260507_1778154329.png) + +- 由于采用串行通信方式,一般DCE设备上需设置时钟频率才可实现通信,而另一端DTE设备则无需设置。另外,目前很多路由器已支持电缆DCE类型及时钟频率的自适应,如思科的ISR路由器等。 + +- **注意**:在现代企业网络中,这种接口已被**以太网(如 GE)**和**光接口**取代,很少再见到新的部署。如果你在设备上看到这个接口,可能是在较老的路由器或模拟器(如 GNS3、EVE-NG)中进行学习。 + +实验设备:Router-PT 2台;Switch_2960 1台;PC 3台;直通线,交叉线,串口线。 + +## 四、实验拓扑: + +![image-20260507200434593](https://gitee.com/onesheet/picture-warehouse/raw/master/pic/upgit_20260507_1778155474.png) + +## 五、实验步骤: + +- 新建Cisco PT 拓扑图 +- 为各PC设置IP及网关地址,其中网关地址分别为路由器接口的IP地址 +- 接着为Router0和Router1上的以太网接口配置IP地址 +- 在路由器之间的串行接口上配置IP地址,且IP地址必须在同一子网内 +- 在Router0的串口上设置时钟频率(本次实验Router0为DCE类型,如图Router0一端有时钟图标) +- 査看路由器上的直连路由 +- 在Router0和Router1上配置静态路由 +- 查看路由器上的静态路由 +- 验证不同局域网PC之间的相互通信 + +```bash +PC设置 +192.168.1.1 //PC0 +192.168.1.2 //PC1 +//子网掩码和网关 +255.255.255.0 +192.168.1.254 + +``` +```bash +PC设置 +192.168.2.1 //PC2 +//子网掩码和网关 +255.255.255.0 +192.168.2.254 + +``` +```bash +Router0 基本配置 +Router>enable +Router#conf t +Router(config)#inter f0/0 //进入第0模块第0端口(快速以太网接口) +Router(config-if)#ip address 192.168.1.254 255.255.255.0 //配置f0/0接口IP +Router(config-if)#no shutdown //开启端口 +Router(config-if)#exit +Router(config)#interface serial 2/0 //进入第2模块第0端口(串行接口) +Router(config-if)#ip address 10.254.10.1 255.255.255.0 //配置s2/0接口IP +Router(config-if)#clock rate 64000 //必须配置时钟才可通信 +Router(config-if)#no shutdown //开启端口 +Router(config)#^Z +Router#show r + +``` +```bash +Router1 基本配置 +Router>enable +Router#conf t +Router(config)#inter f0/0 //进入第0模块第0端口(快速以太网接口) +Router(config-if)#ip address 192.168.2.254 255.255.255.0 //配置f0/0接口IP +Router(config-if)#no shutdown //开启端口 +Router(config-if)#exit +Router(config)#interface serial 2/0 //进入第2模块第0端口(串行接口) +Router(config-if)#ip address 10.254.10.2 255.255.255.0 //配置s2/0接口IP +Router(config-if)#no shutdown //开启端口 +Router(config)#^Z +Router#show r + +``` +```bash +Router0 静态路由配置 +Router>enable +Router#conf t +Router(config)#ip route 192.168.2.0 255.255.255.0 10.254.10.2 +# ip route 目标网络号 目标子网掩码 下一跳地址 +# 命令解读:当目的网络地址为192.168.2.0时,转发到端口地址为10.254.10.2处路由 +Router(config)#^Z +Router#show ip route + +``` +```bash +Router1 静态路由配置 +Router>enable +Router#conf t +Router(config)#ip route 192.168.1.0 255.255.255.0 10.254.10.1 +(命令解读:参考以上) +Router(config)#^Z +Router#show ip route + +``` +```bash +# 链路测试 +PC0和PC1(命令提示符CMD下) +ping 192.168.1.254 //链路通 +ping 10.254.10.2 //链路通 +ping 192.168.2.1 //链路通 +PC2(命令提示符CMD下) +ping 10.254.10.254 //链路通 +ping 192.168.1.2 //链路通 + +``` + +![image-20260509154856750](https://gitee.com/onesheet/picture-warehouse/raw/master/pic/upgit_20260509_1778312937.png) + +# 作业 : + +根据以下网络拓扑图,使用静态路由,让各网络互通! + +### 拓扑图 + +![image-20260509161843889](https://gitee.com/wddaddds/qingzhu-picture-warehouse/raw/master/pic/upgit_20260509_1778314724.png) + +### 代码部分 + +#### R1 + +```bash +Router#conf +Router(config)#h R1 +R1(config)#int f0/0 +R1(config-if)#no shut +R1(config-if)#ip add 192.168.1.254 255.255.255.0 +R1(config-if)#no shut +R1(config-if)#exit +R1(config)#INT S2/0 +R1(config-if)#IP ADD 10.254.10.1 255.0.0.0 +R1(config-if)#NO SHUT + +R1(config-if)#exit + + +R1(config)#do sh ip rout +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 + +C 10.0.0.0/8 is directly connected, Serial2/0 +C 192.168.1.0/24 is directly connected, FastEthernet0/0 + +R1(config)#ip route 192.168.2.0 255.255.255.0 s2/0 +R1(config)#ip route 192.168.3.0 255.255.255.0 s2/0 +R1(config)#do 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 + +C 10.0.0.0/8 is directly connected, Serial2/0 +C 192.168.1.0/24 is directly connected, FastEthernet0/0 +S 192.168.2.0/24 is directly connected, Serial2/0 +S 192.168.3.0/24 is directly connected, Serial2/0 +``` + +#### R2 + +```bash +Router>ena +Router#conf +Router(config)#h R2 +R2(config)#int s2/0 +R2(config-if)#no shut +R2(config-if)#ip add 10.254.10.2 255.0.0.0 +R2(config-if)#no shut +R2(config-if)#exit +R2(config)#int f0/0 +R2(config-if)#no shut +R2(config-if)#ip add 192.168.2.254 +R2(config-if)#ip add 192.168.2.254 255.255.255.0 +R2(config-if)#exit +R2(config)#int s3/0 +R2(config-if)#no shut +R2(config-if)#ip add 20.20.10.1 255.0.0.0 +R2(config-if)#no shut +R2(config-if)#exit + +R2(config)#do sh ip rout +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 + +C 10.0.0.0/8 is directly connected, Serial2/0 +C 20.0.0.0/8 is directly connected, Serial3/0 +C 192.168.2.0/24 is directly connected, FastEthernet0/0 + +R2(config)#ip route 192.168.1.0 255.255.255.0 s2/0 +R2(config)#ip route 192.168.3.0 255.255.255.0 s3/0 +R2(config)#DO SH IP ROUT +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 + +C 10.0.0.0/8 is directly connected, Serial2/0 +C 20.0.0.0/8 is directly connected, Serial3/0 +S 192.168.1.0/24 is directly connected, Serial2/0 +C 192.168.2.0/24 is directly connected, FastEthernet0/0 +S 192.168.3.0/24 is directly connected, Serial3/0 +``` + +#### R3 + +```bash +Router>ena +Router#conf +Router(config)#h R3 +R3(config)#int s3/0 +R3(config-if)#no shut +R3(config-if)#ip add 20.20.10.2 255.0.0.0 +R3(config-if)#exit +R3(config)#int f0/0 +R3(config-if)#no shut +R3(config-if)#ip add 192.168.3.254 255.255.255.0 +R3(config-if)#no shut +R3(config-if)#do 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 + +C 20.0.0.0/8 is directly connected, Serial3/0 +C 192.168.3.0/24 is directly connected, FastEthernet0/0 + +R3(config-if)#exit +R3(config)#ip route 192.168.1.0 255.255.255.0 s3/0 +R3(config)#ip route 192.168.2.0 255.255.255.0 s3/0 +R3(config)#DO SH IP ROUT +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 + +C 20.0.0.0/8 is directly connected, Serial3/0 +S 192.168.1.0/24 is directly connected, Serial3/0 +S 192.168.2.0/24 is directly connected, Serial3/0 +C 192.168.3.0/24 is directly connected, FastEthernet0/0 +``` + +### 结果 + +![image-20260509162531490](https://gitee.com/wddaddds/qingzhu-picture-warehouse/raw/master/pic/upgit_20260509_1778315131.png) + +![image-20260509162552595](https://gitee.com/wddaddds/qingzhu-picture-warehouse/raw/master/pic/upgit_20260509_1778315152.png) + +![image-20260509162607863](https://gitee.com/wddaddds/qingzhu-picture-warehouse/raw/master/pic/upgit_20260509_1778315167.png) + +![image-20260509162626782](https://gitee.com/wddaddds/qingzhu-picture-warehouse/raw/master/pic/upgit_20260509_1778315186.png) + +------ + +# 实践课: + +### 拓扑图 + +![image-20260509155317040](https://gitee.com/wddaddds/qingzhu-picture-warehouse/raw/master/pic/upgit_20260509_1778313197.png) + +### 代码部分 + +#### R1 + +```bash +Router>ena +Router#conf +Router(config)#h R1 +R1(config)#int f0/0 +R1(config-if)#no shut +R1(config-if)#ip add 192.168.1.254 255.255.255.0 +R1(config-if)#no shut +R1(config-if)#exit +R1(config)#int s2/0 +R1(config-if)#ip add 10.254.10.1 255.0.0.0 +R1(config-if)#no shut +R1(config-if)#exit +R1(config)#do sh ip rout +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 + +C 10.0.0.0/8 is directly connected, Serial2/0 +C 192.168.1.0/24 is directly connected, FastEthernet0/0 + +R1(config)#ip route 192.168.2.0 255.255.255.0 10.254.10.2 +R1(config)#ip route 192.168.3.0 255.255.255.0 10.254.10.2 +R1(config)#ip route 192.168.3.0 255.255.255.0 20.20.10.2 +R1(config)#do sh ip rout +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 + +C 10.0.0.0/8 is directly connected, Serial2/0 +C 192.168.1.0/24 is directly connected, FastEthernet0/0 +S 192.168.2.0/24 [1/0] via 10.254.10.2 +S 192.168.3.0/24 [1/0] via 10.254.10.2 + +R1(config)#ip route 172.16.10.0 255.255.255.0 s2/0 +R1(config)#ip route 182.17.10.0 255.255.255.0 s2/0 +R1(config)#do sh ip rout +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 + +C 10.0.0.0/8 is directly connected, Serial2/0 + 172.16.0.0/24 is subnetted, 1 subnets +S 172.16.10.0 is directly connected, Serial2/0 + 182.17.0.0/24 is subnetted, 1 subnets +S 182.17.10.0 is directly connected, Serial2/0 +C 192.168.1.0/24 is directly connected, FastEthernet0/0 +S 192.168.2.0/24 [1/0] via 10.254.10.2 +S 192.168.3.0/24 [1/0] via 10.254.10.2 + + +``` + +------ + +#### R2 + +```bash +Router>ENA +Router#CONF +Router(config)#h R2 +R2(config)#int s2/0 +R2(config-if)#ip add 10.254.10.2 255.0.0.0 +R2(config-if)#no shut +R2(config-if)#exit +R2(config)#int f0/0 +R2(config-if)#ip add 192.168.2.254 255.255.255.0 +R2(config-if)#no shut +R2(config-if)#exit +R2(config)#int s3/0 +R2(config-if)#ip add 20.20.10.1 255.0.0.0 +R2(config-if)#no shut +R2(config-if)#exit +R2(config)#do sh ip rout +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 + +C 10.0.0.0/8 is directly connected, Serial2/0 +C 20.0.0.0/8 is directly connected, Serial3/0 +C 192.168.2.0/24 is directly connected, FastEthernet0/0 + +R2(config)#ip route 192.168.1.0 255.255.255.0 10.254.10.1 +R2(config)#ip route 192.168.3.0 255.255.255.0 20.20.10.2 +R2(config)#do 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 + +C 10.0.0.0/8 is directly connected, Serial2/0 +C 20.0.0.0/8 is directly connected, Serial3/0 +S 192.168.1.0/24 [1/0] via 10.254.10.1 +C 192.168.2.0/24 is directly connected, FastEthernet0/0 +S 192.168.3.0/24 [1/0] via 20.20.10.2 + +R2(config)#ip route 172.16.10.0 255.255.255.0 s3/0 +R2(config)#ip route 182.17.10.0 255.255.255.0 s3/0 + +R2(config)#do 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 + +C 10.0.0.0/8 is directly connected, Serial2/0 +C 20.0.0.0/8 is directly connected, Serial3/0 + 172.16.0.0/24 is subnetted, 1 subnets +S 172.16.10.0 is directly connected, Serial3/0 + 182.17.0.0/24 is subnetted, 1 subnets +S 182.17.10.0 is directly connected, Serial3/0 +S 192.168.1.0/24 [1/0] via 10.254.10.1 +C 192.168.2.0/24 is directly connected, FastEthernet0/0 +S 192.168.3.0/24 [1/0] via 20.20.10.2 + +``` + +#### R3 + +```bash +Router>ENA +Router#CONF +r3(config)#H R3 +R3(config)#int s3/0 +R3(config-if)#ip add 20.20.10.2 255.0.0.0 +R3(config-if)#no shut +R3(config-if)#int f0/0 +R3(config-if)#ip add 192.168.3.254 255.255.255.0 +R3(config-if)#no shut +R3(config-if)#exit +R3(config)#do sh ip rout +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 + +C 20.0.0.0/8 is directly connected, Serial3/0 +C 192.168.3.0/24 is directly connected, FastEthernet0/0 + +R3(config)#ip route 192.168.2.0 255.255.255.0 20.20.10.1 +R3(config)#ip route 192.168.1.0 255.255.255.0 10.254.10.1 +R3(config)#do sh ip rout +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 + +C 20.0.0.0/8 is directly connected, Serial3/0 +S 192.168.2.0/24 [1/0] via 20.20.10.1 +C 192.168.3.0/24 is directly connected, FastEthernet0/0 + +R3(config)#ip route 192.168.1.0 255.255.255.0 10.254.10.1 +R3(config)#ip route 192.168.1.0 255.255.255.0 20.20.10.1 + +R3(config)#exit + +R3#sh ip rout +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 + +C 20.0.0.0/8 is directly connected, Serial3/0 +S 192.168.1.0/24 [1/0] via 20.20.10.1 +S 192.168.2.0/24 [1/0] via 20.20.10.1 +C 192.168.3.0/24 is directly connected, FastEthernet0/0 + +R3(config)#int f1/0 +R3(config-if)#no shut +R3(config-if)#ip add 30.30.1.1 255.0.0.0 +R3(config-if)#exit +R3(config)#ip route 172.16.10.0 255.255.255.0 30.30.1.2 +R3(config)#ip route 182.17.10.0 255.255.255.0 30.30.1.2 +R3(config)#do sh ip rout +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 + +C 20.0.0.0/8 is directly connected, Serial3/0 +C 30.0.0.0/8 is directly connected, FastEthernet1/0 + 172.16.0.0/24 is subnetted, 1 subnets +S 172.16.10.0 [1/0] via 30.30.1.2 + 182.17.0.0/24 is subnetted, 1 subnets +S 182.17.10.0 [1/0] via 30.30.1.2 +S 192.168.1.0/24 [1/0] via 20.20.10.1 +S 192.168.2.0/24 [1/0] via 20.20.10.1 +C 192.168.3.0/24 is directly connected, FastEthernet0/0 + +``` + +#### R4 + +```bash +Router>ena +Router#conf +Configuring from terminal, memory, or network [terminal]? +Enter configuration commands, one per line. End with CNTL/Z. +Router(config)#h R4 + ^ +% Invalid input detected at '^' marker. + +R4(config)#int f0/0 +R4(config-if)#no shut + +R4(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 + +R4(config-if)#ip add 182.17.10.254 +% Incomplete command. +R4(config-if)#ip add 182.17.10.254 255.255.255.0 +R4(config-if)#no shut +R4(config-if)#exit +R4(config)#int f0/0 +R4(config-if)#int f0/0.1 +R4(config-subif)#enc dot 10 +R4(config-subif)#ip add 172.16.10.254 255.255.255.0 +R4(config-subif)#exit +R4(config)#int f0/0.2 +R4(config-subif)#enc dot 20 +R4(config-subif)#exit +R4(config)#int f0/0.2 +R4(config-subif)#ip add 182.17.10.254 255.255.255.0 +R4(config-subif)#no shut +R4(config-subif)#exit +R4(config)#int f1/0 +R4(config-if)#no shut +R4(config-if)#ip add 30.30.1.2 255.0.0.0 +R4(config-if)#exit +R4(config)#do sh ip toute +R4(config)#do 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 + +C 30.0.0.0/8 is directly connected, FastEthernet1/0 + 172.16.0.0/24 is subnetted, 1 subnets +C 172.16.10.0 is directly connected, FastEthernet0/0.1 + 182.17.0.0/24 is subnetted, 1 subnets +C 182.17.10.0 is directly connected, FastEthernet0/0.2 +R4(config)#ip route 192.168.3.0 255.255.255.0 30.30.1.1 +R4(config)#ip route 192.168.2.0 255.255.255.0 30.30.1.1 +R4(config)#ip route 192.168.1.0 255.255.255.0 30.30.1.1 +R4(config)#do sh ip rout +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 + +C 30.0.0.0/8 is directly connected, FastEthernet1/0 + 172.16.0.0/24 is subnetted, 1 subnets +C 172.16.10.0 is directly connected, FastEthernet0/0.1 + 182.17.0.0/24 is subnetted, 1 subnets +C 182.17.10.0 is directly connected, FastEthernet0/0.2 +S 192.168.1.0/24 [1/0] via 30.30.1.1 +S 192.168.2.0/24 [1/0] via 30.30.1.1 +S 192.168.3.0/24 [1/0] via 30.30.1.1 +``` + +### 结果 + +![image-20260509155430422](https://gitee.com/wddaddds/qingzhu-picture-warehouse/raw/master/pic/upgit_20260509_1778313270.png) + +------ + +![image-20260509155459372](https://gitee.com/wddaddds/qingzhu-picture-warehouse/raw/master/pic/upgit_20260509_1778313299.png) + +![image-20260509155518527](https://gitee.com/wddaddds/qingzhu-picture-warehouse/raw/master/pic/upgit_20260509_1778313318.png) + +![image-20260509155532559](https://gitee.com/wddaddds/qingzhu-picture-warehouse/raw/master/pic/upgit_20260509_1778313332.png) + +![image-20260509155544502](https://gitee.com/wddaddds/qingzhu-picture-warehouse/raw/master/pic/upgit_20260509_1778313344.png) \ No newline at end of file -- Gitee