diff --git "a/14 \346\234\261\346\225\254\351\221\253/20250418 \345\212\250\346\200\201\350\267\257\347\224\261.md" "b/14 \346\234\261\346\225\254\351\221\253/20250418 \345\212\250\346\200\201\350\267\257\347\224\261.md" new file mode 100644 index 0000000000000000000000000000000000000000..9eabd473cd80f12d841491a66b70a46a16c83060 --- /dev/null +++ "b/14 \346\234\261\346\225\254\351\221\253/20250418 \345\212\250\346\200\201\350\267\257\347\224\261.md" @@ -0,0 +1,428 @@ +- 最终目标是让各个路由器的路由表都有包含各个网络完整的路由表 +- 如果某个路由器设置了RIP,却缺少某个网络,可能是版本没设置为v2,即version 2 +- 如果中途某个路由器的网络发生了修改,或添加,要主动对外宣告 `直接用network 新连接的网段` +- 如果中途某个路由器的网络关生了关闭或重启,其它路由器会自动处理 + +### 核心代码 + +```cmd +Router(config)#route rip // 启用动态路由RIP协议 ,进入RIP配置模式 +Router(config-router)#version 2 // 选用RIP2版本 +# Router(config-router)#network 当前路由直连的网络 // 向别的路由器通[宣告]告自己所连接的网络 +Router(config-router)#network 192.168.10.0 +``` + + + +![image-20250418155752215](https://gitee.com/bathing-emperor/the-bathing-emperors-bed/raw/master/img/upgit_20250418_1744963072.png) + +#### 路由器配置 + +```cmd +R1 +Router>en + +Router#confi t + +Router(config)#interface g0/1 + +Router(config-if)#no shutdown + +Router(config-if)#ip address 192.168.10.254 255.255.255.0 + +Router(config-if)#ex + +Router(config)#interface g0/0 + +Router(config-if)#no shutdown + +Router(config-if)#ip address 192.168.100.1 255.255.255.0 + +Router(config-if)#ex + +Router(config)#route rip // 启用动态路由RIP协议 ,进入RIP配置模式 + +Router(config-router)#version 2 // 选用RIP2版本 + +Router(config-router)#network 192.168.100.0 // 向别的路由器通[宣告]告自己所连接的网络 + +Router(config-router)#network 192.168.10.0 + + + +R2 +Router> + +Router#confi t + +Router(config)#hostname R2 + +R2(config)#interface g0/0 + +R2(config-if)#ip address 192.168.100.2 255.255.255.0 + +R2(config-if)#ex + +R2(config)#interface g0/0 + +R2(config-if)#no shutdown + +R2(config-if)#interface g0/1 + +R2(config-if)#ip address 192.168.200.1 255.255.255.0 + +R2(config-if)#no shutdown + +R2(config-if)#ex + +R2(config)#route rip + +R2(config-router)#version 2 + +R2(config-router)#network 192.168.100.0 + +R2(config-router)#network 192.168.200.0 + + + +R3 +Router>en + +Router#confi t + +Router(config)#hostname R3 + +R3(config)#interface g0/0 + +R3(config-if)#no shutdown + +R3(config-if)#ip address 192.168.200.2 255.255.255.0 + +R3(config-if)#ex + +R3(config)#interface g0/1 + +R3(config-if)#no shutdown + +R3(config-if)#ip address 192.168.20.254 255.255.255.0 + +R3(config-if)#ex + +R3(config)#route rip + +R3(config-router)#version 2 + +R3(config-router)#network 192.168.200.0 + +R3(config-router)#network 192.168.20.0 + +R3(config-router)#end + +R3#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 + +R 192.168.10.0/24 [120/2] via 192.168.200.1, 00:00:14, GigabitEthernet0/0 + 192.168.20.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.20.0/24 is directly connected, GigabitEthernet0/1 +L 192.168.20.254/32 is directly connected, GigabitEthernet0/1 +R 192.168.100.0/24 [120/1] via 192.168.200.1, 00:00:14, GigabitEthernet0/0 + 192.168.200.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.200.0/24 is directly connected, GigabitEthernet0/0 +L 192.168.200.2/32 is directly connected, GigabitEthernet0/0 +``` + + + +# 作业 + +![image-20250418170315584](https://gitee.com/bathing-emperor/the-bathing-emperors-bed/raw/master/img/upgit_20250418_1744966995.png) + +### 二层交换机配置 + +```cmd +S1 +Switch>en + +Switch#confi t + +·································································实现SVI功能做铺垫 +Switch(config)#interface f0/1 · + · +Switch(config-if)#switchport access vlan 10 · + · +Switch(config-if)#ex · + · +Switch(config)#interface f0/2 · + · +Switch(config-if)#switchport access vlan 20 · + · +Switch(config-if)#ex · + · +Switch(config)#interface f0/3 · + · +Switch(config-if)#switchport mode trunk · +··································································实现SVI功能做铺垫 + +Switch(config-if)#end + +Switch#show vlan b +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 +1002 fddi-default active +1003 token-ring-default active +1004 fddinet-default active +1005 trnet-default + + + +S2 +Switch>en + +Switch#confi t + +·······························································实现单臂路由功能做铺垫 +Switch(config)#interface f0/1 · + · +Switch(config-if)#switchport access vlan 10 · + · +Switch(config-if)#ex · + · +Switch(config)#interface f0/2 · + · +Switch(config-if)#switchport access vlan 20 · + · +Switch(config-if)#ex · + · +Switch(config)#interface f0/3 · + · +Switch(config-if)#switchport mode trunk · +·······························································实现单臂路由功能做铺垫 + +Switch(config-if)#ex + +Switch(config)#end + +Switch#show vlan b +VLAN Name Status Ports +---- -------------------------------- --------- ------------------------------- +1 default active 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 Fa0/1 +20 VLAN0020 active Fa0/2 +1002 fddi-default active +1003 token-ring-default active +1004 fddinet-default active +1005 trnet-default active + + +S3 +Switch>en + +Switch#confi t + +Switch(config)#interface f0/3 + +Switch(config-if)#sw mo tr + +``` + +### 三层交换机配置 + +```cmd +3SW ~~~~~~~~~底下交换机连接的电脑是不同网段,要用到SVI功能 +Switch>en + +Switch#confi t + +·······································································实现SVI功能 +Switch(config)#vlan 10 · + · +Switch(config-vlan)#ex · + · +Switch(config)#vlan 20 · + · +Switch(config-vlan)#ex · + · +Switch(config)#interface f0/1 与二层交换机连接的端口 · + · +Switch(config-if)#switchport trunk encapsulation dot1q //要封装这个协议端口才能改为trunk模式 · + · +Switch(config-if)#switchport mode trunk · + · +Switch(config-if)#ex · + · +Switch(config)#ip routing //开启路由功能 · + · +Switch(config)#interface vlan 10 · + · +Switch(config-if)#ip address 192.168.10.254 255.255.255.0 · + · +Switch(config-if)#ex · + · +Switch(config)#interface vlan 20 · + · +Switch(config-if)#ip address 192.168.40.254 255.255.255.0 · +······································································实现SVI功能 + +Switch(config-if)#ex + +Switch(config)#interface f0/2 + +Switch(config-if)#no switchport //开启三层端口 + +Switch(config-if)#ip address 10.10.1.1 255.255.255.0 + +Switch(config-if)#ex + +Switch(config)#route rip + +Switch(config-router)#version 2 + +Switch(config-router)#network 192.168.10.0 + +Switch(config-router)#network 192.168.40.0 + +Switch(config-router)#network 10.10.1.0 + +Switch(config-router)#end + +Switch#show 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 + + 10.0.0.0/24 is subnetted, 1 subnets +C 10.10.1.0 is directly connected, FastEthernet0/2 +C 192.168.10.0/24 is directly connected, Vlan10 +C 192.168.40.0/24 is directly connected, Vlan20 +``` + +### 路由器配置 + +```cmd +R1 ~~~~~~~~~底下交换机连接的电脑是不同网段,要用单臂路由 +Router>en + +Router#confi t + +···································································实现单臂路由功能 +Router(config)#interface g0/0 | + | +Router(config-if)#ip address 10.10.1.2 255.255.255.0 | + | +Router(config-if)#no shutdown | + | +Router(config-if)#ex | + | +Router(config)#interface g0/2 | + | +Router(config-if)#no shutdown | + | +Router(config-if)#interface g0/2.1 | + | +Router(config-subif)#en | + | +Router(config-subif)#encapsulation dot1Q 10 | + | +Router(config-subif)#ip address 192.168.20.254 255.255.255.0 | + | +Router(config-subif)#ex | + | +Router(config)#interface g0/2.2 | + | +Router(config-subif)#encapsulation dot1Q 20 | + | +Router(config-subif)#ip address 192.168.50.254 255.255.255.0 | + | +Router(config-subif)#ex | + | +Router(config)#interface g0/1 | + | +Router(config-if)#no shutdown | + | +Router(config-if)#ip address 10.10.2.1 255.255.255.0 | +···································································实现单臂路由功能 + +Router(config-if)#end + +Router(config-if)#ex + +Router(config)#route rip + +Router(config-router)#version 2 + +Router(config-router)#network 192.168.20.0 + +Router(config-router)#network 192.168.50.0 + +Router(config-router)#network 10.10.1.0 + +Router(config-router)#network 10.10.2.0 + +Router(config-router)#end + +Router#show ip route + + + + +R2 ~~~~~~~~~底下交换机连接的电脑是相同的网段,用不到单臂路由 +Router>en + +Router#confi t + +Router(config)#interface g0/0/1 + +Router(config-if)#no shutdown + +Router(config-if)#ip address 10.10.2.2 255.255.255.0 + +Router(config-if)#ex + +Router(config)#interface g0/0/0 + +Router(config-if)#no shutdown + +Router(config-if)#ip address 192.168.30.254 255.255.255.0 + +Router(config-if)#ex + +Router(config)#route rip + +Router(config-router)#version 2 + +Router(config-router)#network 10.10.2.0 + +Router(config-router)#network 192.168.30.0 + +Router(config-router)#end + +Router#show ip route +``` +