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 0000000000000000000000000000000000000000..109780b8d5fb2d1e7023f9687886e8e41e9aac1f --- /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 +``` + 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 0000000000000000000000000000000000000000..1947f9eeb26daa3c6186125adc7d76dfde0a6fbf --- /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 diff --git "a/15 \351\273\204\346\265\267\351\221\253/20260512 RIP\345\212\250\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/20260512 RIP\345\212\250\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 0000000000000000000000000000000000000000..cab7b9dd18b6677aee93cb29c5b9af10241702cd --- /dev/null +++ "b/15 \351\273\204\346\265\267\351\221\253/20260512 RIP\345\212\250\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,366 @@ +## 路由器动态路由(RIP)配置 + +### 1、实验目的:  + +- 掌握RIP动态路由选择协议的配置方法 + +- 掌握路由选择表中的RIP路由描述 + +- 熟悉路由选择和分组转发的原理及过程 + +### 2、实验背景: + +- 公司通过一台三层交换机连到企业网的出口路由器上,路由器再与互联网服务提供商 ISP的另一台路由器连接。现要企业网设备上做适当配置,实现企业网内部主机与外网主机之间的相互通信。为了简化网管的管理维护工作,公司决定采用动态路由配置 —— RIPv2协议实现互通。 + +### 3、技术原理: + +- 动态路由选择:路由器使用路由选择协议(算法)根据实测或估计的距离、时延和网络拓扑等度量权值,自动计算最佳路径并建立路由表。相比静态路由选择,它配置手段更加便捷,适合应用于中大型且网络拓扑变化频繁的网络环境;但另一方面则会占用更多的路由器CPU资源和网络带宽。 + +- 路由选择协议可分为3大类,只有理解不同路由选择协议的工作方式,才能根据实际情况具体分析,从而最大程度上满足具体的应用需要: + + - 距离矢量:通过判断s距离确定当前到达目的网络的最佳路径。如RIP、IGRP等 + + - 链路状态:通过发送本路由器与哪些路由器相邻,及其链路状态(距离、时延等)信息,如OSPF等 + + - 混合型:同时具有距离矢量和链路状态两种协议的特性,如EIGRP等 + +- 路由信息协议(Routing Information Protocls,即 RIP),是应用较早、使用较普遍的IGP内部路由协议,使用于小型同类网络的一种距离矢量协议,规定**最大跳数为15**,有以下两个版本: + + - RIPv1:属于有类路由协议,不支持VLSM,以广播形式进行路由更新,更新周期30s; + + - RIPv2:属于无类路由协议,支持VLSM(‌**[VLSM](https://www.baidu.com/s?rsv_dl=re_dqa_generate&sa=re_dqa_generate&wd=VLSM&rsv_pq=a38d325a00828124&oq=VLSM&rsv_t=6dd3Ws9FDkCkvMKA0YejLkMqcZpeWmhzGoLhG5naIBOSsptKCIKagUEj6Ko&tn=baidu&ie=utf-8)(Variable Length Subnet Mask,可变长度子网掩码)**‌是一种网络技术,允许在一个网络中使用多种子网掩码,以提高IP地址的使用效率和网络管理的灵活性),以组播形式进行路由更新; + +- 路由配置模式            Router(config-router)# + + + +‌**RIP协议的最大跳数为15**‌。RIP(Routing Information Protocol)是一种距离向量路由协议,它使用跳数来度量网络中两个节点之间的距离。RIP协议的最大跳数是15,超过这个值的路径将被丢弃,表示网络不可达‌12。 + +跳数是指路由器在搜索最优路径时允许跳跃的最大次数。RIP协议通过跳数来衡量网络中的距离,每个经过的路由器称为一跳。当跳数达到15时,该路由仍视为有效;若跳数超过15(即16),则认为目标网络不可达‌。 + +### 4、实验拓扑: + +实验设备:PT-Router 2台;Switch_3560 1台;PC 3台;直通线,交叉线,串口线。 + +![image-20250508111242762](https://gitee.com/onesheet/picture-warehouse/raw/master/pic/upgit_20260512_1778574269.png) + + +### 5、实验步骤: + +- 新建Cisco PT 拓扑图 +- 为各PC设置IP及网关地址,其中网关地址分别为路由接口的IP地址 +- 对三层交换机Switch1进行相关配置(VLAN、SVI及路由等) +- 接着为Router0和Router1上的以太网接口配置IP地址 +- 在路由器之间的串行接口上配置IP地址,且IP地址必须在同一子网内 +- 在Router0的串口上设置时钟频率(本次实验Router0为DCE类型,如图Router0一端有时钟图标) +- 査看路由器上的直连路由 +- 在Router0和Router1上配置RIP动态路由 +- 查看路由器上的动态路由 +- 验证不同局域网PC之间的相互通信 + + +```bash +PC设置 +192.168.1.2 //PC0 +192.168.1.3 //PC1 +//子网掩码和网关 +255.255.255.0 +192.168.1.1 + +``` + +```bash +PC设置 +192.168.2.2 //PC2 +//子网掩码和网关 +255.255.255.0 +192.168.2.1 + +``` + +```bash +/*=Part1 S3560 VLAN配置 */ +Switch>en +Switch#config t +Switch(config)#vlan 10 //创建VLAN 10 +Switch(config-vlan)#name vlan10 +Switch(config-vlan)#vlan 20 //创建VLAN 20 +Switch(config-vlan)#name vlan20 +Switch(config-vlan)#exit +Switch(config)#inter range f0/1,fa0/3 +Switch(config-if-range)#switchport access vlan 10 //设置端口模式为Access +Switch(config-if-range)#exit +Switch(config)#inter f0/2 +Switch(config-if)#switchport access vlan 20 //设置端口模式为Access +Switch(config-if)#exit +/*=Part2 SVI路由配置 */ +Switch(config)#ip routing //开启路由功能,默认关闭 +Switch(config)#interface vlan 10 //进入SVI接口模式,接口自动开启 +Switch(config-if)#ip address 192.168.1.1 255.255.255.0 //配置SVI接口IP +Switch(config-if)#exit +Switch(config)#interface vlan 20 +Switch(config-if)#ip address 192.168.3.1 255.255.255.0 +Switch(config-if)#exit +/*=Part3 RIP动态路由配置 */ +Switch(config)#router rip //进入路由配置模式 — 启用RIP协议 +Switch(config-router)#version 2 //使用版本2,即RIPv2协议 +Switch(config-router)#network 192.168.1.0 //指定需要通告的网络地址(位于SVI接口) +Switch(config-router)#network 192.168.3.0 +Switch(config)#end +Switch#show r +Switch#show ip route +``` + +```bash +/*=Part1 Router0 基本配置 */ +Router>enable +Router#conf t +Router(config)#inter f0/0 //进入第0模块第0端口(快速以太网接口) +Router(config-if)#ip address 192.168.3.2 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 192.168.4.1 255.255.255.0 //配置s2/0接口IP +Router(config-if)#clock rate 64000 //必须配置时钟才可通信 +Router(config-if)#no shutdown //开启端口,默认关闭 +Router(config-if)#exit +/*=Part2 RIP动态路由配置 */ +Router(config)#router rip //进入路由配置模式 — 启用RIP协议 +Router(config-router)#version 2 //使用版本2,即RIPv2协议 +Router(config-router)#network 192.168.3.0 //指定需要通告的网络地址(位于路由接口) +Router(config-router)#network 192.168.4.0 +Router(config-router)#end +Router#show r +Router#show ip route + +``` + +```bash +/*=Part1 Router1 基本配置 */ +Router>enable +Router#conf t +Router(config)#inter f0/0 //进入第0模块第0端口(快速以太网接口) +Router(config-if)#ip address 192.168.2.1 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 192.168.4.2 255.255.255.0 //配置s2/0接口IP +Router(config-if)#no shutdown //开启端口,默认关闭 +Router(config)#exit +/*=Part2 RIP动态路由配置 */ +Router(config)#router rip //进入路由配置模式 — 启用RIP协议 +Router(config-router)#version 2 //使用版本2,即RIPv2协议 +Router(config-router)#network 192.168.2.0 //指定需要通告的网络地址(位于路由接口) +Router(config-router)#network 192.168.4.0 +Router(config-router)#end +Router#show r +Router#show ip route + +``` + +```bash +# 链路测试 +PC0和PC2(命令提示符CMD下) +ping 192.168.1.1 //内网链路通 +ping 192.168.4.1 //外网链路通 +ping 192.168.2.2 //目的网络链路通 +PC1(命令提示符CMD下) +ping 192.168.4.1 //链路通 +ping 192.168.3.1 //链路通 +ping 192.168.1.3 //链路通 + +``` + +------ + +# 作业 + +## 拓扑图 + +![image-20260512165721781](https://gitee.com/wddaddds/qingzhu-picture-warehouse/raw/master/pic/upgit_20260512_1778576242.png) + +## 代码 + +### RSW + +```bash +Switch>ena +Switch#conf +Switch(config)#h RSW +RSW(config)#ip routing +RSW(config)#int f0/1 +RSW(config-if)#no sw +RSW(config-if)#ip add 192.168.1.254 255.255.255.0 +RSW(config-if)#no shut +RSW(config-if)#exit +RSW(config)#int f0/2 +RSW(config-if)#no sw +RSW(config-if)# +RSW(config-if)#ip add 200.16.1.5 255.255.255.252 +RSW(config-if)#no shut +RSW(config-if)#exit +RSW(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 192.168.1.0/24 is directly connected, FastEthernet0/1 + 200.16.1.0/30 is subnetted, 1 subnets +C 200.16.1.4 is directly connected, FastEthernet0/2 + +RSW(config)#route rip +RSW(config-router)#ver 2 +RSW(config-router)#net 192.168.1.0 +RSW(config-router)#net 200.16.1.4 +RSW(config-router)#EXIT +RSW(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 192.168.1.0/24 is directly connected, FastEthernet0/1 +R 192.168.2.0/24 [120/1] via 200.16.1.6, 00:00:02, FastEthernet0/2 +R 192.168.3.0/24 [120/2] via 200.16.1.6, 00:00:02, FastEthernet0/2 + 200.16.1.0/30 is subnetted, 1 subnets +C 200.16.1.4 is directly connected, FastEthernet0/2 +R 200.16.2.0/24 [120/1] via 200.16.1.6, 00:00:02, FastEthernet0/2 +``` + +------ + +### RA + +```bash +Router>ena +Router#conf +Router(config)#h RA +RA(config)#int f0/0 +RA(config-if)#no shut +RA(config-if)#ip add 200.16.1.6 255.255.255.252 +RA(config-if)#int f0/1 +RA(config-if)#no shut +RA(config-if)#ip add 192.168.2.254 255.255.255.0 +RA(config-if)#no shut +RA(config-if)#exit +RA(config)#int s0/0/0 +RA(config-if)#ip add 200.16.2.5 255.255.255.252 +RA(config-if)#no shut +RA(config-if)#clock rate 64000 +RA(config-if)#no shut +RA(config-if)#exit +RA(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 192.168.2.0/24 is directly connected, FastEthernet0/1 + 200.16.1.0/30 is subnetted, 1 subnets +C 200.16.1.4 is directly connected, FastEthernet0/0 + 200.16.2.0/30 is subnetted, 1 subnets +C 200.16.2.4 is directly connected, Serial0/0/0 + +RA(config)#route rip +RA(config-router)#ver 2 +RA(config-router)#net 192.168.2.0 +RA(config-router)#net 200.16.1.4 +RA(config-router)#net 200.16.2.4 +RA(config-router)#exit +RA(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 + +R 192.168.1.0/24 [120/1] via 200.16.1.5, 00:00:27, FastEthernet0/0 +C 192.168.2.0/24 is directly connected, FastEthernet0/1 +R 192.168.3.0/24 [120/1] via 200.16.2.6, 00:00:12, Serial0/0/0 + 200.16.1.0/30 is subnetted, 1 subnets +C 200.16.1.4 is directly connected, FastEthernet0/0 + 200.16.2.0/30 is subnetted, 1 subnets +C 200.16.2.4 is directly connected, Serial0/0/0 +``` + +------ + +### RB + +```bash +Router>ena +Router#conf +RB\(config)#H RB +RB(config)#int s0/0/1 +RB(config-if)#no shut +RB(config-if)#ip add 200.16.2.6 255.255.255.252 +RB(config-if)#no shut +RB(config-if)#exit +RB(config)#int f0/1 +RB(config-if)#no shut +RB(config-if)#ip add 192.168.3.254 255.255.255.0 +RB(config-if)#no shut +RB(config-if)#exit +RB(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 192.168.3.0/24 is directly connected, FastEthernet0/1 + 200.16.2.0/30 is subnetted, 1 subnets +C 200.16.2.4 is directly connected, Serial0/0/1 + +RB(config)#route rip +RB(config-router)#ver 2 +RB(config-router)#net 192.168.3.0 +RB(config-router)#net 200.16.2.4 +RB(config-router)#do sh ip routedo +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 + +R 192.168.1.0/24 [120/2] via 200.16.2.5, 00:00:22, Serial0/0/1 +R 192.168.2.0/24 [120/1] via 200.16.2.5, 00:00:22, Serial0/0/1 +C 192.168.3.0/24 is directly connected, FastEthernet0/1 +R 200.16.1.0/24 [120/1] via 200.16.2.5, 00:00:22, Serial0/0/1 + 200.16.2.0/30 is subnetted, 1 subnets +C 200.16.2.4 is directly connected, Serial0/0/1 +``` + +------ + +## 结果 + +![image-20260512170516138](https://gitee.com/wddaddds/qingzhu-picture-warehouse/raw/master/pic/upgit_20260512_1778576716.png) \ No newline at end of file diff --git "a/15 \351\273\204\346\265\267\351\221\253/20260513 \350\267\257\347\224\261\345\231\250\351\235\231\346\200\201\350\267\257\347\224\261\345\217\212RIP\343\200\201OSPF\345\212\250\346\200\201\350\267\257\347\224\261\351\205\215\347\275\256v2.md" "b/15 \351\273\204\346\265\267\351\221\253/20260513 \350\267\257\347\224\261\345\231\250\351\235\231\346\200\201\350\267\257\347\224\261\345\217\212RIP\343\200\201OSPF\345\212\250\346\200\201\350\267\257\347\224\261\351\205\215\347\275\256v2.md" new file mode 100644 index 0000000000000000000000000000000000000000..d9c0daf96dcba8d50e41ed4cc1ad747a0dd9c672 --- /dev/null +++ "b/15 \351\273\204\346\265\267\351\221\253/20260513 \350\267\257\347\224\261\345\231\250\351\235\231\346\200\201\350\267\257\347\224\261\345\217\212RIP\343\200\201OSPF\345\212\250\346\200\201\350\267\257\347\224\261\351\205\215\347\275\256v2.md" @@ -0,0 +1,1335 @@ +# 路由器静态路由及RIP、OSPF动态路由配置 + +## 一、路由器静态路由配置 + +### 1、实验目的:  + +- 掌握静态路由的配置方法和应用 + +- 掌握路由选择表中的路由描述 + +- 熟悉路由选择和分组转发的原理及过程 + +### 2、实验背景: + +- 某公司除总部外,另有一处分部,并且都有一个独立的局域网,为了使公司各部之间能相互通信,共享资源。每个出口利用一台路由器进行连接,两台路由器间公司申请了一条DDN专线(数字数据网)进行相连,要求做适当配置实现相互访问。 + +### 3、技术原理: + +- 路由器属于网络层设备,能够根据IP数据报的首部信息,选择一条最佳路径(这一过程称为"路由选择"),将数据报转发到下一跳路由地址,并最终传送到目的结点(这一过程称为"分组转发"),从而实现不同局域网(或逻辑子网)的主机之间的互相访问。 + +- 路由器是根据路由表进行选路和转发的。而路由表里就是由一条条路由信息组成。不同厂商路由器生成的路由表结构及内容可能有所差异,内容主要包括:路由源码(路由选择方式)、目的网络及其掩码、下一跳路由地址或端口、默认路由等信息。 + +- 生成路由表主要有两种方法:手工配置和动态配置,即静态路由协议配置和动态路由协议配置。 + + - 静态路由:由网络管理员手工配置固定的路由信息。具有简单、高效、可靠以及安全保密性高等优点。 + + - 动态路由:路由器利用动态路由协议(如RIP、OSPF等)自动建立路由表,并能根据实际网络拓扑结构的变化适时更新,无需管理员手工维护,适用于网络规模大、拓扑复杂的网络。 + +- 缺省/默认路由:静态路由的一种特殊情况。当数据包在査找路由表时,没有找到和目标相匹配的路由表项时,若没有配置默认路由,即指定路由器默认的下一跳地址,则路由器会将该数据包丢弃。 + +- 路由器通常通过串行端口连接广域网络,两端分别以DCE(数据通信设备)、DTE设备(数据终端设备)区分,对于标准的串行端口,其接口针脚的分配相反,一般DTE是针头(俗称公头),DCE是孔头(俗称母头),从而实现对接。 + +- 由于采用串行通信方式,一般DCE设备上需设置时钟频率才可实现通信,而另一端DTE设备则无需设置。另外,目前很多路由器已支持电缆DCE类型及时钟频率的自适应,如思科的ISR路由器等。 + + + +**注:DCE与DTE接口的区别及案例** + +**1. 基本定义** +- **DTE(Data Terminal Equipment,数据终端设备)**:生成或消费数据的终端设备,如计算机、路由器(作为终端时)。 +- **DCE(Data Communication Equipment,数据通信设备)**:负责网络通信的中间设备,提供时钟、同步及链路管理,如调制解调器、部分广域网接口的路由器。 + +**2. 核心区别** + +| **区别点** | **DTE** | **DCE** | +| ------------ | ------------------------------- | ------------------------------------ | +| **角色** | 数据源或终点(如发送/接收文件) | 数据传输中介(如转换信号、管理链路) | +| **时钟控制** | 使用DCE提供的时钟同步 | **主动提供时钟信号**(如串口速率) | +| **物理接口** | 发送引脚(如Tx)与DCE的Rx对应 | 接收引脚(如Rx)与DTE的Tx对应 | + +**3. 简单案例** +**场景**:两个路由器通过串行电缆(如V.35)连接,构建广域网链路。 +- **DCE端**:其中一台路由器需配置时钟速率(如`clock rate 64000`),负责控制数据传输时序。 +- **DTE端**:另一台路由器无需配置时钟,直接使用DCE提供的同步信号。 + +**说明**: + +- DCE设备(如配置了时钟的路由器)确保链路两端速率一致,避免数据不同步。 +- 线缆需匹配DTE-DCE角色(如DCE端使用DCE电缆,DTE端使用DTE电缆),否则需交叉线缆。 + +**总结**:DCE是链路的“协调者”,负责时钟与同步;DTE是数据的“发起者/接收者”。理解二者的角色对网络设备配置(如广域网连接)至关重要。 + +![](https://img-blog.csdnimg.cn/20210421195224476.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzMzOTgwNDY1,size_16,color_FFFFFF,t_70) + + + +### 4、实验拓扑: + +实验设备:PT-Router 2台;Switch_2960 1台;PC 3台;直通线,交叉线,串口线。 + +![20240425221116](https://oss.9ihub.com/test/20240425221116.png) + +### 5、实验步骤: + +- 新建Cisco PT 拓扑图 +- 为各PC设置IP及网关地址,其中网关地址分别为路由器接口的IP地址 +- 接着为Router0和Router1上的以太网接口配置IP地址 +- 由于2811路由器缺少路由之间的连接设备,需要在路由器物理接口列表中,往路由器添加NM-8A/S接口 +- 在路由器之间的串行接口上配置IP地址,且IP地址必须在同一子网内 +- 在Router0的串口上设置时钟频率(本次实验Router0为DCE类型,如图Router0一端有时钟图标,频率为64000) +- 査看路由器上的直连路由 +- 在Router0和Router1上配置静态路由 +- 查看路由器上的静态路由 +- 验证不同局域网PC之间的相互通信 + +```bash +PC设置 +192.168.1.2 //PC0 +192.168.1.3 //PC1 +//子网掩码和网关 +255.255.255.0 +192.168.1.1 + +``` + +```bash +PC设置 +192.168.2.2 //PC2 +//子网掩码和网关 +255.255.255.0 +192.168.2.1 + +``` + +```bash +Router0 基本配置 +Router>enable +Router#conf t +Router(config)#inter f0/0 //进入第0模块第0端口(快速以太网接口) +Router(config-if)#ip address 192.168.1.1 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-if)#exit +Router(config)#ip route 192.168.2.0 255.255.255.0 10.254.10.2 //静态路由配置 +(命令解读:当目的网络地址为192.168.2.0时,转发到端口地址为10.254.10.2处路由) +Router(config)#end +Router#show r +Router#show ip route + +``` + +```bash +Router1 基本配置 +Router>enable +Router#conf t +Router(config)#inter f0/0 //进入第0模块第0端口(快速以太网接口) +Router(config-if)#ip address 192.168.2.1 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-if)#exit //开启端口 +Router(config)#ip route 192.168.1.0 255.255.255.0 10.254.10.1 //静态路由配置 +(命令解读:当目的网络地址为192.168.1.0时,转发到端口地址为10.254.10.1处路由) +Router(config)#end +Router#show r +Router#show ip route + +``` + + + +```bash +# 链路测试 +PC0和PC1(命令提示符CMD下) +ping 192.168.1.1 //链路通 +ping 10.254.10.2 //链路通 +ping 192.168.2.2 //链路通 +PC1(命令提示符CMD下) +ping 10.254.10.1 //链路通 +ping 192.168.1.3 //链路通 + +``` + + + +## 二、路由器动态路由(RIP)配置 + +### 1、实验目的:  + +- 掌握RIP动态路由选择协议的配置方法 + +- 掌握路由选择表中的RIP路由描述 + +- 熟悉路由选择和分组转发的原理及过程 + +### 2、实验背景: + +- 公司通过一台三层交换机连到企业网的出口路由器上,路由器再与互联网服务提供商 ISP的另一台路由器连接。现要企业网设备上做适当配置,实现企业网内部主机与外网主机之间的相互通信。为了简化网管的管理维护工作,公司决定采用动态路由配置 —— RIPv2协议实现互通。 + +### 3、技术原理: + +- 动态路由选择:路由器使用路由选择协议(算法)根据实测或估计的距离、时延和网络拓扑等度量权值,自动计算最佳路径并建立路由表。相比静态路由选择,它配置手段更加便捷,适合应用于中大型且网络拓扑变化频繁的网络环境;但另一方面则会占用更多的路由器CPU资源和网络带宽。 + +- 路由选择协议可分为3大类,只有理解不同路由选择协议的工作方式,才能根据实际情况具体分析,从而最大程度上满足具体的应用需要: + + - 距离矢量:通过判断s距离确定当前到达目的网络的最佳路径。如RIP、IGRP等 + + - 链路状态:通过发送本路由器与哪些路由器相邻,及其链路状态(距离、时延等)信息,如OSPF等 + + - 混合型:同时具有距离矢量和链路状态两种协议的特性,如EIGRP等 + +- 路由信息协议(Routing Information Protocls,即 RIP),是应用较早、使用较普遍的IGP内部路由协议,使用于小型同类网络的一种距离矢量协议,规定**最大跳数为15**,有以下两个版本: + + - RIPv1:属于有类路由协议,不支持VLSM,以广播形式进行路由更新,更新周期30s; + + - RIPv2:属于无类路由协议,支持VLSM(‌**[VLSM](https://www.baidu.com/s?rsv_dl=re_dqa_generate&sa=re_dqa_generate&wd=VLSM&rsv_pq=a38d325a00828124&oq=VLSM&rsv_t=6dd3Ws9FDkCkvMKA0YejLkMqcZpeWmhzGoLhG5naIBOSsptKCIKagUEj6Ko&tn=baidu&ie=utf-8)(Variable Length Subnet Mask,可变长度子网掩码)**‌是一种网络技术,允许在一个网络中使用多种子网掩码,以提高IP地址的使用效率和网络管理的灵活性),以组播形式进行路由更新; + +- 路由配置模式            Router(config-router)# + + + +‌**RIP协议的最大跳数为15**‌。RIP(Routing Information Protocol)是一种距离向量路由协议,它使用跳数来度量网络中两个节点之间的距离。RIP协议的最大跳数是15,超过这个值的路径将被丢弃,表示网络不可达‌12。 + +跳数是指路由器在搜索最优路径时允许跳跃的最大次数。RIP协议通过跳数来衡量网络中的距离,每个经过的路由器称为一跳。当跳数达到15时,该路由仍视为有效;若跳数超过15(即16),则认为目标网络不可达‌。 + +### 4、实验拓扑: + +实验设备:PT-Router 2台;Switch_3560 1台;PC 3台;直通线,交叉线,串口线。 + +![image-20250508111242762](.\imgs16\1.png) + + + + +### 5、实验步骤: + +- 新建Cisco PT 拓扑图 +- 为各PC设置IP及网关地址,其中网关地址分别为路由接口的IP地址 +- 对三层交换机Switch1进行相关配置(VLAN、SVI及路由等) +- 接着为Router0和Router1上的以太网接口配置IP地址 +- 在路由器之间的串行接口上配置IP地址,且IP地址必须在同一子网内 +- 在Router0的串口上设置时钟频率(本次实验Router0为DCE类型,如图Router0一端有时钟图标) +- 査看路由器上的直连路由 +- 在Router0和Router1上配置RIP动态路由 +- 查看路由器上的动态路由 +- 验证不同局域网PC之间的相互通信 + + +```bash +PC设置 +192.168.1.2 //PC0 +192.168.1.3 //PC1 +//子网掩码和网关 +255.255.255.0 +192.168.1.1 + +``` + +```bash +PC设置 +192.168.2.2 //PC2 +//子网掩码和网关 +255.255.255.0 +192.168.2.1 + +``` + +```bash +/*=Part1 S3560 VLAN配置 */ +Switch>en +Switch#config t +Switch(config)#vlan 10 //创建VLAN 10 +Switch(config-vlan)#name vlan10 +Switch(config-vlan)#vlan 20 //创建VLAN 20 +Switch(config-vlan)#name vlan20 +Switch(config-vlan)#exit +Switch(config)#inter range f0/1,fa0/3 +Switch(config-if-range)#switchport access vlan 10 //设置端口模式为Access +Switch(config-if-range)#exit +Switch(config)#inter f0/2 +Switch(config-if)#switchport access vlan 20 //设置端口模式为Access +Switch(config-if)#exit +/*=Part2 SVI路由配置 */ +Switch(config)#ip routing //开启路由功能,默认关闭 +Switch(config)#interface vlan 10 //进入SVI接口模式,接口自动开启 +Switch(config-if)#ip address 192.168.1.1 255.255.255.0 //配置SVI接口IP +Switch(config-if)#exit +Switch(config)#interface vlan 20 +Switch(config-if)#ip address 192.168.3.1 255.255.255.0 +Switch(config-if)#exit +/*=Part3 RIP动态路由配置 */ +Switch(config)#router rip //进入路由配置模式 — 启用RIP协议 +Switch(config-router)#version 2 //使用版本2,即RIPv2协议 +Switch(config-router)#network 192.168.1.0 //指定需要通告的网络地址(位于SVI接口) +Switch(config-router)#network 192.168.3.0 +Switch(config)#end +Switch#show r +Switch#show ip route +``` + +```bash +/*=Part1 Router0 基本配置 */ +Router>enable +Router#conf t +Router(config)#inter f0/0 //进入第0模块第0端口(快速以太网接口) +Router(config-if)#ip address 192.168.3.2 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 192.168.4.1 255.255.255.0 //配置s2/0接口IP +Router(config-if)#clock rate 64000 //必须配置时钟才可通信 +Router(config-if)#no shutdown //开启端口,默认关闭 +Router(config-if)#exit +/*=Part2 RIP动态路由配置 */ +Router(config)#router rip //进入路由配置模式 — 启用RIP协议 +Router(config-router)#version 2 //使用版本2,即RIPv2协议 +Router(config-router)#network 192.168.3.0 //指定需要通告的网络地址(位于路由接口) +Router(config-router)#network 192.168.4.0 +Router(config-router)#end +Router#show r +Router#show ip route + +``` + +```bash +/*=Part1 Router1 基本配置 */ +Router>enable +Router#conf t +Router(config)#inter f0/0 //进入第0模块第0端口(快速以太网接口) +Router(config-if)#ip address 192.168.2.1 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 192.168.4.2 255.255.255.0 //配置s2/0接口IP +Router(config-if)#no shutdown //开启端口,默认关闭 +Router(config)#exit +/*=Part2 RIP动态路由配置 */ +Router(config)#router rip //进入路由配置模式 — 启用RIP协议 +Router(config-router)#version 2 //使用版本2,即RIPv2协议 +Router(config-router)#network 192.168.2.0 //指定需要通告的网络地址(位于路由接口) +Router(config-router)#network 192.168.4.0 +Router(config-router)#end +Router#show r +Router#show ip route + +``` + +```bash +# 链路测试 +PC0和PC2(命令提示符CMD下) +ping 192.168.1.1 //内网链路通 +ping 192.168.4.1 //外网链路通 +ping 192.168.2.2 //目的网络链路通 +PC1(命令提示符CMD下) +ping 192.168.4.1 //链路通 +ping 192.168.3.1 //链路通 +ping 192.168.1.3 //链路通 + +``` + + + +## 三、路由器动态路由(OSPF)配置 + +### 1、实验目的:  + +- 掌握OSPF动态路由选择协议的配置方法 + +- 掌握路由选择表中的OSPF路由描述 + +- 熟悉路由选择和分组转发的原理及过程 + +### 2、实验背景: + +- 公司通过一台三层交换机连到企业网的出口路由器上,路由器再与互联网服务提供商 ISP的另一台路由器连接。现要企业网设备上做适当配置,实现企业网内部主机与外网主机之间的相互通信。为了简化网管的管理维护工作,公司决定采用动态路由配置 —— OSPF协议实现互通。 + +### 3、技术原理: + +- 路由器通过路由选择协议建立了一个正确、稳定的路由表后,每当收到IP分组时,会将其沿着一条从源结点到达目的结点的最佳路径进行转发,大致过程如下: + + 1. 首先检查数据分组头中的目的IP地址,并计算出目的网络 + 2. 若表中给出了到达目的网络的下一跳路由器的IP地址,则按给出的路径将该IP分组 + 3. 当下一跳路由器接收到该IP分组后,同样进行类似处理并转发,最终该IP分 + 4. 若目的网络是与路由器的端口直连的,则直接将IP分组转发到路 + 5. 若在路由表中既没有下一跳路由地址,也没有目的端口,则将IP分组 + 6. 若没有设置默认路由或在默认路由中仍没有该目的网络的路由信息,则直接将该IP分组丢弃。 + +- 开放式最短路径优先协议(Open Shortest Path First,即OSPF),是目前网络中应用最广泛的路由协议之一,通过向全网扩散本设备的链路状态信息,使网络中每台设备最终同步一个具有全网链路状态的数据库,然后采用 SPF 算法,以自身为根,计算到达其他网络的最短路径,最终形成全网路由信息。具有以下特点: + + - 采取分层路由的设计,可划分区域,支持大型互联网环境; + - 允许多开发商的设备集成(开放标准); + - 支持可变长掩码(VLSM)和无类别域间路由(CIDR); + - 没有限制路由的最大跳数; + - 内含3个彼此独立的表:①用于跟踪直连的邻居路由器(邻居关系数据库);②用于确定整个网络的拓扑结构(拓扑数据库);③用作路由选择表; + - 路由更新采用组播报文; + +- OSPF基本配置包括:启用并运行OSPF进程,在该进程下配置路由器所属的区域、区域范围和区域内参与OSPF路由的网络地址。 + + - OSPF的配置比RIP要复杂得多,除了基本配置外,OSPF有许多复杂的可选项配置,如配置引入外部路由时默认Cost值、Tag值等;OSPF认证方式;指定邻居路由器;设置被动接口;路由过滤等等。 + +- OSPF区域:由一组相邻的网络和路由器组成,在同一区域内的所有路由器共享一个区域ID。区域ID是指定给特定的路由接口上,路由器上可拥有多个区域ID,而区域0是必不可少的主干区域,同一区域中的所有路由器拥有相同的拓扑表。 + + - 与OSPF进程ID的区别:OSPF进程ID对一系列的OSPF配置命令进行分组,是一个只具有本地意义的值(起始值为1),因此不同的OSPF路由器无须使用相同的进程ID来完成通信。可同时运行多个OSPF进程,用于拓扑数据库的备份。 + +- 不同于RIP配置,命令network的参数由网络地址和通配符掩码组成,该组合用于标识OSPF操作的接口。其中通配符掩码用于与源或目标地址一起来确定匹配的地址范围,0表示精确匹配,1表示任意匹配,它与子网掩码是完全不同的概念。 + +实验设备:Router-PT 2台;Switch_3560 1台;PC 3台;直通线,交叉线,串口线。 + +### 4、实验拓扑: + +![image-20240815102108656](.\imgs16\2.png) + +### 5、实验步骤: + +- 新建Cisco PT 拓扑图 +- 为各PC设置IP及网关地址,其中网关地址分别为路由接口的IP地址 +- 对三层交换机Switch1进行相关配置(VLAN、OSPF等) +- 接着为Router0和Router1上的以太网接口配置IP地址 +- 在路由器之间的串行接口上配置IP地址,且IP地址必须在同一子网内 +- 在Router0的串口上设置时钟频率(本次实验Router0为DCE类型,如图Router0一端有时钟图标,频率64000) +- 査看路由器上的直连路由 +- 在Router0和Router1上配置OSPF动态路由 +- 查看路由器上的动态路由 +- 验证不同局域网PC之间的相互通信 + + +```bash +PC设置 +192.168.1.2 //PC0 +192.168.1.3 //PC1 +//子网掩码和网关 +255.255.255.0 +192.168.1.1 + +``` + +```bash +PC设置 +192.168.2.2 //PC2 +//子网掩码和网关 +255.255.255.0 +192.168.2.1 +``` + +```bash +/*=Part1 S3560 VLAN配置 */ +Switch>en +Switch#config t +Switch(config)#vlan 10 //创建VLAN 2 +Switch(config-vlan)#name vlan10 +Switch(config-vlan)#vlan 20 //创建VLAN 3 +Switch(config-vlan)#name vlan20 +Switch(config-vlan)#exit +Switch(config)#inter range f0/1,f0/3 +Switch(config-if-range)#switchport access vlan 10 //设置端口模式为Access +Switch(config-if-range)#exit +Switch(config)#inter f0/2 +Switch(config-if)#switchport access vlan 20 //设置端口模式为Access +Switch(config-if)#exit + +/*=Part2 SVI路由配置 */ +Switch(config)#ip routing //开启路由功能,默认关闭 +Switch(config)#interface vlan 10 //进入SVI接口模式,接口自动开启 +Switch(config-if)#ip address 192.168.1.1 255.255.255.0 //配置SVI接口IP +Switch(config-if)#exit +Switch(config)#interface vlan 20 +Switch(config-if)#ip address 192.168.3.1 255.255.255.0 +Switch(config-if)#exit + +/*=Part3 OSPF动态路由配置 */ +Switch(config)#router ospf 1 //启用OSPF协议,从属OSPF进程ID=1(进程ID是一个32位数字(范围是 1 到 4294967295),一个路由器允许配置多个OSPF进程ID) +//指定通告网络,并归属OSPF区域ID=0 +Switch(config-router)#network 192.168.1.0 0.0.0.255 area 0 +#network 192.168.1.0 0.0.0.255(反掩码) area 0(归属区域) +Switch(config-router)#network 192.168.3.0 0.0.0.255 area 0 +Switch(config)#end +Switch#show r +Switch#show ip route + +``` + +```bash +/*=Part1 Router0 基本配置 */ +Router>enable +Router#conf t +Router(config)#inter f0/0 //进入第0模块第0端口(快速以太网接口) +Router(config-if)#ip address 192.168.3.2 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-if)#exit +/*=Part2 OSPF动态路由配置 */ +Router(config)#router ospf 1 //启用OSPF协议,从属OSPF进程ID=1(进程ID是一个32位数字(范围是 1 到 4294967295),一个路由器允许配置多个OSPF进程ID) +//指定通告网络,并归属OSPF区域ID=0 +Router(config-router)#network 192.168.3.0 0.0.0.255 area 0 +Router(config-router)#network 192.168.4.0 0.0.0.255 area 0 +Router(config-router)#end +Router#show r +Router#show ip route + +``` + +```bash +/*=Part1 Router1 基本配置 */ +Router>enable +Router#conf t +Router(config)#inter f0/0 //进入第0模块第0端口(快速以太网接口) +Router(config-if)#ip address 192.168.2.1 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)#exit +/*=Part2 OSPF动态路由配置 */ +Router(config)#router ospf 1 //启用OSPF协议,从属OSPF进程ID=1(进程ID是一个32位数字(范围是 1 到 4294967295),一个路由器允许配置多个OSPF进程ID) +//指定通告网络,并归属OSPF区域ID=0 +Router(config-router)#network 192.168.2.0 0.0.0.255 area 0 +Router(config-router)#network 192.168.4.0 0.0.0.255 area 0 +Router(config-router)#end +Router#show r +Router#show ip route + +``` + +```bash +# 链路测试 +PC0和PC1(命令提示符CMD下) +ping 192.168.1.1 //内网链路通 +ping 192.168.4.1 //外网链路通 +ping 192.168.2.2 //目的网络链路通 +PC2(命令提示符CMD下) +ping 192.168.4.1 //链路通 +ping 192.168.3.1 //链路通 +ping 192.168.1.3 //链路通 +``` + + + + + +# 三种路由的写法 + +```bash +# 静态路由,写死的,而且写的是对方的信息,就是要将所有要到达的网络,都手写写一次,路由越多,要写的越多 +# 1 路由器连接* 10路由器 = 11个路由器,一共要配置 11个路由器。 一共个路由器里要配置的条数 10*11 +ip route 要连接的网络地址 子网掩码 下一跳的地址 +ip route 192.168.2.0 255.255.255.0 20.20.20.2 +ip route 192.168.3.0 255.255.255.0 20.20.20.2 +ip route 192.168.4.0 255.255.255.0 20.20.20.2 +ip route 192.168.5.0 255.255.255.0 20.20.20.2 + + +# 动态路由的思想,自己宣告自己的网络,别的路由自己来学习 +# 1 路由器连接* 10路由器 = 11个路由器,一共要配置 11个路由器。 一共11条 +# 动态路由之RIP协议,有跳数限制,也较慢 + route rip + version 2 + # 主动宣告自己的网络给别人 + network 192.168.1.0 + +# 动态路由之OSPF协议,最短路径,没有跳数限制,是流行的协议 ,大中型网络中常用 + route ospf 1 + network 网络地址 子网掩码的反码 area 0 + # 怎么计算反码 + # 255.255.255.255 - 子网掩码 + # 255.255.255.0 + # 0.0.0.255 +``` + + + + + +作业: +![image-20260513095535986](https://gitee.com/onesheet/picture-warehouse/raw/master/pic/upgit_20260513_1778637336.png) + +## **OSPF代码** + +#### RT1 + +```bash +Router>ena +Router#conf +Router(config)#h RT1 +RT1(config)#int g0/2 +RT1(config-if)#ip add 100.100.100.254 255.255.255.0 +RT1(config-if)#no shut +RT1(config-if)#exit +RT1(config)#int g0/0 +RT1(config-if)#no shut +RT1(config-if)#int g0/0.1 +RT1(config-subif)#enc dot1Q 40 +RT1(config-subif)#ip add 192.168.40.254 255.255.255.0 +RT1(config-subif)#no shut +RT1(config-subif)#exit +RT1(config)#int g0/0.2 +RT1(config-subif)#enc do 50 +RT1(config-subif)#ip add 192.168.50.254 255.255.255.0 +RT1(config-subif)#no shut +RT1(config-subif)#exit +RT1(config)#int g0/1 +RT1(config-if)#ip add 192.168.10.1 255.255.255.0 +RT1(config-if)#no shut +RT1(config-if)#exit +RT1(config)#do sh ip rout +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 + + 100.0.0.0/8 is variably subnetted, 2 subnets, 2 masks +C 100.100.100.0/24 is directly connected, GigabitEthernet0/2 +L 100.100.100.254/32 is directly connected, GigabitEthernet0/2 + 192.16.40.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.40.0/24 is directly connected, GigabitEthernet0/0.1 +L 192.168.40.254/32 is directly connected, GigabitEthernet0/0.1 + 192.168.10.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.10.0/24 is directly connected, GigabitEthernet0/1 +L 192.168.10.1/32 is directly connected, GigabitEthernet0/1 + 192.168.50.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.50.0/24 is directly connected, GigabitEthernet0/0.2 +L 192.168.50.254/32 is directly connected, GigabitEthernet0/0.2 + +RT1(config)#route ospf 1 +RT1(config-router)#net 100.100.100.0 255.255.255.0 area 0 +RT1(config-router)#net 192.168.10.0 255.255.255.0 area 0 +RT1(config-router)#net 192.168.40.0 255.255.255.0 area 0 +RT1(config-router)#net 192.168.50.0 255.255.255.0 a 0 +RT1(config-router)#exit +RT1(config-router)#exit +RT1(config)#do sh 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 + + 100.0.0.0/8 is variably subnetted, 2 subnets, 2 masks +C 100.100.100.0/24 is directly connected, GigabitEthernet0/2 +L 100.100.100.254/32 is directly connected, GigabitEthernet0/2 + 192.168.10.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.10.0/24 is directly connected, GigabitEthernet0/1 +L 192.168.10.1/32 is directly connected, GigabitEthernet0/1 +O 192.168.20.0/24 [110/2] via 192.168.10.2, 00:00:18, GigabitEthernet0/1 +O 192.168.30.0/24 [110/3] via 192.168.10.2, 00:00:18, GigabitEthernet0/1 + 192.168.40.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.40.0/24 is directly connected, GigabitEthernet0/0.1 +L 192.168.40.254/32 is directly connected, GigabitEthernet0/0.1 + 192.168.50.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.50.0/24 is directly connected, GigabitEthernet0/0.2 +L 192.168.50.254/32 is directly connected, GigabitEthernet0/0.2 +O 192.168.60.0/24 [110/2] via 192.168.10.2, 00:09:24, GigabitEthernet0/1 +O 192.168.70.0/24 [110/2] via 192.168.10.2, 00:09:14, GigabitEthernet0/1 +``` + +------ + +#### SW1 + +```bash +Switch>ena +Switch#conf +Switch(config)#h SW1 +SW1(config)#ip routing +SW1(config)#int f0/2 +SW1(config-if)#no sw +SW1(config-if)#ip add 192.168.10.2 255.255.255.0 +SW1(config-if)#no shut +SW1(config-if)#exit +SW1(config)#vlan 60 +SW1(config-vlan)#exit +SW1(config)#vlan 70 +SW1(config-vlan)#exit +SW1(config)#int vlan 60 +SW1(config-if)#ip add 192.168.60.254 255.255.255.0 +SW1(config-if)#no shut +SW1(config-if)#exit +SW1(config)#int vlan 70 +SW1(config-if)#ip add 192.168.70.254 255.255.255.0 +SW1(config-if)#no shut +SW1(config-if)#exit +SW1(config)#int f0/3 +SW1(config-if)#no sw +SW1(config-if)#ip add 192.168.20.1 255.255.255.0 +SW1(config-if)#no shut +SW1(config-if)#int f0/1 +SW1(config-if)#swi tr enc do +SW1(config-if)#sw mo tr +SW1(config-if)#exit +SW1(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 192.168.10.0/24 is directly connected, FastEthernet0/2 +C 192.168.20.0/24 is directly connected, FastEthernet0/3 +C 192.168.60.0/24 is directly connected, Vlan60 +C 192.168.70.0/24 is directly connected, Vlan70 + +SW1(config)#route ospf 1 +SW1(config-router)#net 192.168.10.0 255.255.255.0 a 0 +SW1(config-router)#net 192.168.20.0 255.255.255.0 a 0 +SW1(config-router)#net 192.168.60.0 255.255.255.0 a 0 +SW1(config-router)#net 192.168.70.0 255.255.255.0 a 0 +SW1(config-router)#exit +SW1(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 + + 100.0.0.0/24 is subnetted, 1 subnets +O 100.100.100.0 [110/2] via 192.168.10.1, 00:07:38, FastEthernet0/2 +C 192.168.10.0/24 is directly connected, FastEthernet0/2 +C 192.168.20.0/24 is directly connected, FastEthernet0/3 +O 192.168.40.0/24 [110/2] via 192.168.10.1, 00:07:38, FastEthernet0/2 +O 192.168.50.0/24 [110/2] via 192.168.10.1, 00:03:41, FastEthernet0/2 +C 192.168.60.0/24 is directly connected, Vlan60 +C 192.168.70.0/24 is directly connected, Vlan70 +``` + +#### RT2 + +```bash +Router>ena +Router#conf +Router(config)#h RT2 +RT2(config)#int g0/0 +RT2(config-if)#ip add 192.168.20.2 255.255.255.0 +RT2(config-if)#no shut +RT2(config-if)#exit +RT2(config)#int g0/1 +RT2(config-if)#no shut +RT2(config-if)#ip add 192.168.30.254 255.255.255.0 +RT2(config-if)#exit +RT2(config)#do sh 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.20.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.20.0/24 is directly connected, GigabitEthernet0/0 +L 192.168.20.2/32 is directly connected, GigabitEthernet0/0 + 192.168.30.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.30.0/24 is directly connected, GigabitEthernet0/1 +L 192.168.30.254/32 is directly connected, GigabitEthernet0/1 + +RT2(config)#route ospf 1 +RT2(config-router)#net 190.168.20.0 255.255.255.0 a 0 +RT2(config-router)#net 192.168.30.0 255.255.255.0 a 0 + +RT2(config-router)#exit +RT2(config)#do sh ip rout +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 + + 100.0.0.0/24 is subnetted, 1 subnets +O 100.100.100.0/24 [110/3] via 192.168.20.1, 00:09:05, GigabitEthernet0/0 +O 192.168.10.0/24 [110/2] via 192.168.20.1, 00:09:05, GigabitEthernet0/0 + 192.168.20.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.20.0/24 is directly connected, GigabitEthernet0/0 +L 192.168.20.2/32 is directly connected, GigabitEthernet0/0 + 192.168.30.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.30.0/24 is directly connected, GigabitEthernet0/1 +L 192.168.30.254/32 is directly connected, GigabitEthernet0/1 +O 192.168.40.0/24 [110/3] via 192.168.20.1, 00:09:05, GigabitEthernet0/0 +O 192.168.50.0/24 [110/3] via 192.168.20.1, 00:09:05, GigabitEthernet0/0 +O 192.168.60.0/24 [110/2] via 192.168.20.1, 00:09:05, GigabitEthernet0/0 +O 192.168.70.0/24 [110/2] via 192.168.20.1, 00:09:05, GigabitEthernet0/0 + +``` + +#### SW3 + +```bash +Switch>ena +Switch#conf +Configuring from terminal, memory, or network [terminal]? +Enter configuration commands, one per line. End with CNTL/Z. +Switch(config)#h SW3 +SW3(config)#vlan 40 +SW3(config-vlan)#exit +SW3(config)#vlan 50 +SW3(config-vlan)#exit +SW3(config)#int f0/1 +SW3(config-if)#sw mo tr + +SW3(config-if)# +%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down + +%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up + +SW3(config-if)#exit +SW3(config)#int f0/2 +SW3(config-if)#swi acc vlan 40 +SW3(config-if)#exit +SW3(config)#int f0/3 +SW3(config-if)#swi acc vlan 50 +``` + +------ + +#### SW2 + +```bash +Switch>ena +Switch#conf +Configuring from terminal, memory, or network [terminal]? +Enter configuration commands, one per line. End with CNTL/Z. +Switch(config)#h SW2 +SW2(config)#vlan 60 +SW2(config-vlan)#exit +SW2(config)#vlan 70 +SW2(config-vlan)#exit +SW2(config)#int f0/2 +SW2(config-if)#swi acc vlan 60 +SW2(config-if)#ex +%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down + +%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up +it +SW2(config)# +SW2(config)#int f0/3 +SW2(config-if)#swi acc vlan 70 +SW2(config-if)#exit +SW2(config)# + +``` + +------ + +#### 结果 + +![image-20260513105206639](https://gitee.com/wddaddds/qingzhu-picture-warehouse/raw/master/pic/upgit_20260513_1778640727.png) + +------ + +### **RIP V2代码** + +#### RT1 + +```bash +Router>ena +Router#conf +Router(config)#h RT1 +RT1(config)#int g0/2 +RT1(config-if)#ip add 100.100.100.254 255.255.255.0 +RT1(config-if)#no shut +RT1(config-if)#exit +RT1(config)#int g0/0 +RT1(config-if)#no shut +RT1(config-if)#int g0/0.1 +RT1(config-subif)#enc do 40 +RT1(config-subif)#ip add 192.168.40.254 255.255.255.0 +RT1(config-subif)#exit +RT1(config)#int g0/0.2 +RT1(config-subif)#enc do 50 +RT1(config-subif)#ip add 192.168.50.254 255.255.255.0 +RT1(config-subif)#no shut +RT1(config-subif)#exit +RT1(config)#int g0/1 +RT1(config-if)#ip add 192.168.10.1 255.255.255.0 +RT1(config-if)#no shut +RT1(config)#int g0/0 +RT1(config-if)#EXIT +RT1(config)#do sh 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 + + 100.0.0.0/8 is variably subnetted, 2 subnets, 2 masks +C 100.100.100.0/24 is directly connected, GigabitEthernet0/2 +L 100.100.100.254/32 is directly connected, GigabitEthernet0/2 + 192.168.10.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.10.0/24 is directly connected, GigabitEthernet0/1 +L 192.168.10.1/32 is directly connected, GigabitEthernet0/1 + 192.168.40.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.40.0/24 is directly connected, GigabitEthernet0/0.1 +L 192.168.40.254/32 is directly connected, GigabitEthernet0/0.1 + 192.168.50.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.50.0/24 is directly connected, GigabitEthernet0/0.2 +L 192.168.50.254/32 is directly connected, GigabitEthernet0/0.2 + +RT1(config)#route rip +RT1(config-router)#ver 2 +RT1(config-router)#net 100.100.100.0 +RT1(config-router)#net 192.168.10.0 +RT1(config-router)#net 192.168.40.0 +RT1(config-router)#net 192.168.50.0 +RT1(config-router)#exit +RT1(config)#do sh ip rout +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 + + 100.0.0.0/8 is variably subnetted, 2 subnets, 2 masks +C 100.100.100.0/24 is directly connected, GigabitEthernet0/2 +L 100.100.100.254/32 is directly connected, GigabitEthernet0/2 + 192.168.10.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.10.0/24 is directly connected, GigabitEthernet0/1 +L 192.168.10.1/32 is directly connected, GigabitEthernet0/1 +R 192.168.20.0/24 [120/1] via 192.168.10.2, 00:00:05, GigabitEthernet0/1 +R 192.168.30.0/24 [120/2] via 192.168.10.2, 00:00:05, GigabitEthernet0/1 + 192.168.40.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.40.0/24 is directly connected, GigabitEthernet0/0.1 +L 192.168.40.254/32 is directly connected, GigabitEthernet0/0.1 + 192.168.50.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.50.0/24 is directly connected, GigabitEthernet0/0.2 +L 192.168.50.254/32 is directly connected, GigabitEthernet0/0.2 +R 192.168.60.0/24 [120/1] via 192.168.10.2, 00:00:05, GigabitEthernet0/1 +R 192.168.70.0/24 [120/1] via 192.168.10.2, 00:00:05, GigabitEthernet0/1 +``` + +------ + +#### SW1 + +```bash +Switch>ena +Switch#conf +Configuring from terminal, memory, or network [terminal]? +Enter configuration commands, one per line. End with CNTL/Z. +Switch(config)#h SW1 +SW1(config)#ip routing +SW1(config)#int f0/2 +SW1(config-if)#no sw +SW1(config-if)#ip add 192.168.10.2 255.255.255.0 +SW1(config-if)#exit +SW1(config)#vlan 60 +SW1(config-vlan)#exit +SW1(config)#vlan 70 +SW1(config-vlan)# +SW1(config-vlan)#exit +SW1(config)#int f0/1 +SW1(config-if)#swi tr enc do +SW1(config-if)#sw mo tr +SW1(config)#int vlan 60 +SW1(config-if)#ip add 192.168.60.254 255.255.255.0 +SW1(config-if)#int vlan 70 +SW1(config-if)#ip add 192.168.70.254 255.255.255.0 +SW1(config-if)#exit +SW1(config)#int f0/3 +SW1(config-if)#no sw +SW1(config-if)#ip add 192.168.20.1 255.255.255.0 +SW1(config-if)#no shut +SW1(config-if)#exit +SW1(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 192.168.10.0/24 is directly connected, FastEthernet0/2 +C 192.168.20.0/24 is directly connected, FastEthernet0/3 +C 192.168.60.0/24 is directly connected, Vlan60 +C 192.168.70.0/24 is directly connected, Vlan70 + +SW1(config)# route rip +SW1(config-router)#ver 2 +SW1(config-router)#net 192.168.10.0 +SW1(config-router)#net 192.168.20.0 +SW1(config-router)#net 192.168.60.0 +SW1(config-router)#net 192.168.70.0 +SW1(config-router)#EXIT +SW1(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 + +R 100.0.0.0/8 [120/1] via 192.168.10.1, 00:00:01, FastEthernet0/2 +C 192.168.10.0/24 is directly connected, FastEthernet0/2 +C 192.168.20.0/24 is directly connected, FastEthernet0/3 +R 192.168.30.0/24 [120/1] via 192.168.20.2, 00:00:16, FastEthernet0/3 +R 192.168.40.0/24 [120/1] via 192.168.10.1, 00:00:01, FastEthernet0/2 +R 192.168.50.0/24 [120/1] via 192.168.10.1, 00:00:01, FastEthernet0/2 +C 192.168.60.0/24 is directly connected, Vlan60 +C 192.168.70.0/24 is directly connected, Vlan70 + +``` + +------ + +#### RT2 + +```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 RT2 +RT2(config)#INT G0/0 +RT2(config-if)#IP ADD 192.168.20.2 255.255.255.0 +RT2(config-if)#NO SHUT +RT2(config)#INT G0/1 +RT2(config-if)#IP ADD 192.168.30.254 255.255.255.0 +RT2(config-if)#NO SHUT +RT2(config-if)#exit +RT2(config)#do sh 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.20.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.20.0/24 is directly connected, GigabitEthernet0/0 +L 192.168.20.2/32 is directly connected, GigabitEthernet0/0 + 192.168.30.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.30.0/24 is directly connected, GigabitEthernet0/1 +L 192.168.30.254/32 is directly connected, GigabitEthernet0/1 + +RT2(config)#route rip +RT2(config-router)#ver 2 +RT2(config-router)#net 192.168.20.0 +RT2(config-router)#net 192.168.30.0 +RT2(config-router)#EXIT +RT2(config)#DO SH IP ROUT +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 + +R 100.0.0.0/8 [120/2] via 192.168.20.1, 00:00:02, GigabitEthernet0/0 +R 192.168.10.0/24 [120/1] via 192.168.20.1, 00:00:02, GigabitEthernet0/0 + 192.168.20.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.20.0/24 is directly connected, GigabitEthernet0/0 +L 192.168.20.2/32 is directly connected, GigabitEthernet0/0 + 192.168.30.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.30.0/24 is directly connected, GigabitEthernet0/1 +L 192.168.30.254/32 is directly connected, GigabitEthernet0/1 +R 192.168.40.0/24 [120/2] via 192.168.20.1, 00:00:02, GigabitEthernet0/0 +R 192.168.50.0/24 [120/2] via 192.168.20.1, 00:00:02, GigabitEthernet0/0 +R 192.168.60.0/24 [120/1] via 192.168.20.1, 00:00:02, GigabitEthernet0/0 +R 192.168.70.0/24 [120/1] via 192.168.20.1, 00:00:02, GigabitEthernet0/0 + +``` + + + +------ + + + +#### 结果 + +![image-20260513110308417](https://gitee.com/wddaddds/qingzhu-picture-warehouse/raw/master/pic/upgit_20260513_1778641388.png) + +------ + +### 静态路由代码 + +#### RT1 + +```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 RT1` +RT1`(config)#h RT1# +RT1#(config)#int g0/0 +RT1#(config-if)#no shut + +RT1#(config-if)#exit +RT1#(config)#int g0/0.1 +RT1#(config-subif)#enc do 40 +RT1#(config-subif)#ip add 192.168.40.254 255.255.255.0 +RT1#(config-subif)#no shut +RT1#(config-subif)#exit +RT1#(config)#int g0/0.2 +RT1#(config-subif)# +RT1#(config-subif)#enc dot1Q 50 +RT1#(config-subif)#ip add 192.168.50.254 255.255.255.0 +RT1#(config-subif)#no shut +RT1#(config-subif)#int g0/1 +RT1#(config-if)#ip add 192.168.10.1 255.255.255.0 +RT1#(config-if)#no shut +RT1#(config)#h RT1 +RT1#conf +RT1(config)#int g0/2 +RT1(config-if)#no shut +RT1(config-if)#ip add 100.100.100.254 255.255.255.0 +RT1(config-if)#exit +RT1(config)#do sh ip rout +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 + + 100.0.0.0/8 is variably subnetted, 2 subnets, 2 masks +C 100.100.100.0/24 is directly connected, GigabitEthernet0/2 +L 100.100.100.254/32 is directly connected, GigabitEthernet0/2 + 192.168.10.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.10.0/24 is directly connected, GigabitEthernet0/1 +L 192.168.10.1/32 is directly connected, GigabitEthernet0/1 + 192.168.40.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.40.0/24 is directly connected, GigabitEthernet0/0.1 +L 192.168.40.254/32 is directly connected, GigabitEthernet0/0.1 + 192.168.50.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.50.0/24 is directly connected, GigabitEthernet0/0.2 +L 192.168.50.254/32 is directly connected, GigabitEthernet0/0.2 + +RT1(config)#ip route 192.168.20.0 255.255.255.0 192.168.10.2 +RT1(config)#ip route 192.168.60.0 255.255.255.0 192.168.10.2 +RT1(config)#ip route 192.168.70.0 255.255.255.0 192.168.10.2 +RT1(config)#ip route 192.168.30.0 255.255.255.0 192.168.10.2 +RT1(config)#do sh ip rout +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 + + 100.0.0.0/8 is variably subnetted, 2 subnets, 2 masks +C 100.100.100.0/24 is directly connected, GigabitEthernet0/2 +L 100.100.100.254/32 is directly connected, GigabitEthernet0/2 + 192.168.10.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.10.0/24 is directly connected, GigabitEthernet0/1 +L 192.168.10.1/32 is directly connected, GigabitEthernet0/1 +S 192.168.20.0/24 [1/0] via 192.168.10.2 +S 192.168.30.0/24 [1/0] via 192.168.10.2 + 192.168.40.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.40.0/24 is directly connected, GigabitEthernet0/0.1 +L 192.168.40.254/32 is directly connected, GigabitEthernet0/0.1 + 192.168.50.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.50.0/24 is directly connected, GigabitEthernet0/0.2 +L 192.168.50.254/32 is directly connected, GigabitEthernet0/0.2 +S 192.168.60.0/24 [1/0] via 192.168.10.2 +S 192.168.70.0/24 [1/0] via 192.168.10.2 + +``` + +------ + +#### SW1 + +```bash +Switch>ena +Switch#conf +Switch(config)#h SW1 +SW1(config)#ip routing +SW1(config)#int f0/2 +SW1(config-if)#no sw +SW1(config-if)#ip add 192.168.10.2 255.255.255.0 +SW1(config-if)#no shut +SW1(config-if)#exit +SW1(config)#vlan 60 +SW1(config-vlan)#exit +SW1(config)#vlan 70 +SW1(config-vlan)#exit +SW1(config)#int vlan 60 +SW1(config-if)#ip add 192.168.60.254 255.255.255.0 +SW1(config-if)#no sh +SW1(config-if)#exit +SW1(config)#int vlan 70 +SW1(config-if)#ip add 192.168.70.254 255.255.255.0 +SW1(config-if)#no shut +SW1(config-if)#int f0/3 +SW1(config-if)#no sw +SW1(config-if)#ip add 192.168.20.1 255.255.255.0 +SW1(config-if)#no shut +SW1(config-if)#int f0/1 +SW1(config-if)#swi tr enc do +SW1(config-if)#sw mo tr +SW1(config-if)#end +SW1#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 192.168.10.0/24 is directly connected, FastEthernet0/2 +C 192.168.20.0/24 is directly connected, FastEthernet0/3 +C 192.168.60.0/24 is directly connected, Vlan60 +C 192.168.70.0/24 is directly connected, Vlan70 +SW1#conf +SW1(config)#ip route 192.168.40.0 255.255.255.0 192.168.10.1 +SW1(config)#ip route 192.168.50.0 255.255.255.0 192.168.10.1 +SW1(config)#ip route 100.100.100.0 255.255.255.0 192.168.10.1 +SW1(config)#ip route 192.168.30.0 255.255.255.0 192.168.20.2 +SW1(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 + + 100.0.0.0/24 is subnetted, 1 subnets +S 100.100.100.0 [1/0] via 192.168.10.1 +C 192.168.10.0/24 is directly connected, FastEthernet0/2 +C 192.168.20.0/24 is directly connected, FastEthernet0/3 +S 192.168.30.0/24 [1/0] via 192.168.20.2 +S 192.168.40.0/24 [1/0] via 192.168.10.1 +S 192.168.50.0/24 [1/0] via 192.168.10.1 +C 192.168.60.0/24 is directly connected, Vlan60 +C 192.168.70.0/24 is directly connected, Vlan70 + +``` + +------ + +#### RT2 + +```bash +Router>ENA +Router#CONF +Router(config)#int g0/0 +Router(config-if)#ip add 192.168.20.2 255.255.255.0 +Router(config-if)#no shut +Router(config-if)#exit +Router(config)#H RT2 +RT2(config)#int g0/1 +RT2(config-if)#no shut +RT2(config-if)#ip add 192.168.30.254 255.255.255.0 +RT2(config)#do sh 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.20.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.20.0/24 is directly connected, GigabitEthernet0/0 +L 192.168.20.2/32 is directly connected, GigabitEthernet0/0 + 192.168.30.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.30.0/24 is directly connected, GigabitEthernet0/1 +L 192.168.30.254/32 is directly connected, GigabitEthernet0/1 + +RT2(config)#ip route 192.168.10.0 255.255.255.0 192.168.20.1 +RT2(config)#ip route 192.168.40.0 255.255.255.0 192.168.20.1 +RT2(config)#ip route 192.168.50.0 255.255.255.0 192.168.20.1 +RT2(config)#ip route 192.168.60.0 255.255.255.0 192.168.20.1 +RT2(config)#ip route 192.168.70.0 255.255.255.0 192.168.20.1 +RT2(config)#ip route 100.100.100.0 255.255.255.0 192.168.20.1 +RT2(config)#DO SH 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 + + 100.0.0.0/24 is subnetted, 1 subnets +S 100.100.100.0/24 [1/0] via 192.168.20.1 +S 192.168.10.0/24 [1/0] via 192.168.20.1 + 192.168.20.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.20.0/24 is directly connected, GigabitEthernet0/0 +L 192.168.20.2/32 is directly connected, GigabitEthernet0/0 + 192.168.30.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.30.0/24 is directly connected, GigabitEthernet0/1 +L 192.168.30.254/32 is directly connected, GigabitEthernet0/1 +S 192.168.40.0/24 [1/0] via 192.168.20.1 +S 192.168.50.0/24 [1/0] via 192.168.20.1 +S 192.168.60.0/24 [1/0] via 192.168.20.1 +S 192.168.70.0/24 [1/0] via 192.168.20.1 + +``` + +------ + + + +#### 结果 + +![image-20260513125649862](https://gitee.com/wddaddds/qingzhu-picture-warehouse/raw/master/pic/upgit_20260513_1778648209.png)