diff --git "a/43\346\236\227\346\200\241\347\220\264/20240510_\344\270\211\345\261\202\344\272\244\346\215\242\346\234\272.md" "b/43\346\236\227\346\200\241\347\220\264/20240510_\344\270\211\345\261\202\344\272\244\346\215\242\346\234\272.md" new file mode 100644 index 0000000000000000000000000000000000000000..24f8932124df3d397f6bb17d532b4024b0211c3b --- /dev/null +++ "b/43\346\236\227\346\200\241\347\220\264/20240510_\344\270\211\345\261\202\344\272\244\346\215\242\346\234\272.md" @@ -0,0 +1,185 @@ +##### 三层交换机 + +- trunk模式 + + ```c# + swi trunk encapsulation dot1q + ``` + +- 开启路由功能(**连接不同的网络,要启用路由功能**) + + ```c# + ip routing + ``` + +- 启用三层接口,并取消二层接口,当路由器可以设IP + + ```c# + no switchport + ``` + + + +##### 作业 + +1. 作业一 + + ![image-20240510193108865](./imgs/05101.png) + + - 第一台三层交换机 + + ```c# + Switch>en + Switch#conf t + Switch(config)#vlan 10 + Switch(config-vlan)#vlan 20 + Switch(config-vlan)#int f0/1 + Switch(config-if)#swi acc vlan 10 + Switch(config-if)#int f0/2 + Switch(config-if)#swi acc vlan 20 + Switch(config-if)#int vlan 10 + Switch(config-if)#ip add 192.168.10.254 255.255.255.0 + Switch(config-if)#int vlan 20 + Switch(config-if)#ip add 192.168.20.254 255.255.255.0 + Switch(config-if)#ex + Switch(config)#ip routing + Switch(config)#int f0/3 + Switch(config-if)#swi t enc d + Switch(config-if)#no swi + Switch(config-if)#ip add 192.168.1.1 255.255.255.0 + Switch(config)#ro ospf 1 + Switch(config-router)#net 192.168.1.0 0.0.0.255 a 0 + Switch(config-router)#net 192.168.10.0 0.0.0.255 a 0 + Switch(config-router)#net 192.168.20.0 0.0.0.255 a 0 + ``` + + + + - 第二台三层交换机 + + ```c# + Switch>en + Switch#conf t + Switch(config)#vlan 30 + Switch(config-vlan)#vlan 40 + Switch(config-vlan)#int f0/1 + Switch(config-if)#swi acc vlan 30 + Switch(config-if)#int f0/2 + Switch(config-if)#swi acc vlan 40 + Switch(config-if)#int vlan 30 + Switch(config-if)#ip add 192.168.30.254 255.255.255.0 + Switch(config-if)#int vlan 40 + Switch(config-if)#ip add 192.168.40.254 255.255.255.0 + Switch(config-if)#ex + Switch(config)#ip routing + Switch(config)#int f0/3 + Switch(config-if)#swi t enc d + Switch(config-if)#no swi + Switch(config-if)#ip add 192.168.1.2 255.255.255.0 + Switch(config)#ro ospf 1 + Switch(config-router)#net 192.168.1.0 0.0.0.255 a 0 + Switch(config-router)#net 192.168.2.0 0.0.0.255 a 0 + Switch(config-router)#net 192.168.30.0 0.0.0.255 a 0 + Switch(config-router)#net 192.168.40.0 0.0.0.255 a 0 + + ``` + + - 路由器 + + ```c# + Router>en + Router#conf t + Router(config-if)#int f0/1 + Router(config-if)#no shu + Router(config-if)#int f0/1.1 + Router(config-subif)#enc d 50 + Router(config-subif)#ip add 192.168.50.254 255.255.255.0 + Router(config-subif)#no shu + Router(config-subif)#int f0/1.2 + Router(config-subif)#enc d 60 + Router(config-subif)#ip add 192.168.60.254 255.255.255.0 + Router(config-subif)#no shu + Router(config-subif)#int f0/0 + Router(config-if)#ip add 192.168.2.2 255.255.255.0 + Router(config-if)#no shu + Router(config-if)#do show ip r + Router(config-if)#ex + Router(config)#rou ospf 1 + Router(config-router)#net 192.168.2.0 0.0.0.255 a 0 + Router(config-router)#net 192.168.50.0 0.0.0.255 a 0 + Router(config-router)#net 192.168.60.0 0.0.0.255 a 0 + Router(config-router)#do show ip ro + + ``` + + ![image-20240510193438598](./imgs/05102.png) + + ![image-20240510193534746](./imgs/05103.png) + +2. 作业二 + + ![image-20240510202812238](./imgs/05106.png) + + - 交换机配置 + + ```c# + Switch>en + Switch#conf t + Switch(config)#host SW1 + SW1(config-vlan)#int f0/1 + SW1(config-if)#swi acc vlan 11 + SW1(config-if)#int f0/2 + SW1(config-if)#swi acc vlan 21 + SW1(config-if)#int f0/3 + SW1(config-if)#swi m t + + ``` + + - R1路由器配置 + + ```c# + Router>en + Router#conf t + Router(config)#host R1 + R1(config)#line vty 0 4 + R1(config-line)#pass 123456 + R1(config-line)#login + R1(config-line)#int f0/1 + R1(config-if)#ip add 192.168.21.17 255.255.255.240 + R1(config-if)#no shu + R1(config-if)#int f0/0 + R1(config-if)#ip add 192.168.21.1 255.255.255.240 + R1(config-if)#no shu + R1(config-if)#ex + R1(config)#ro ospf 1 + R1(config-router)#net 192.168.21.0 0.0.0.15 a 0 + R1(config-router)#net 192.168.21.16 0.0.0.15 a 0 + ``` + + - R2路由器配置 + + ```c# + Router>en + Router#conf t + Router(config)#int f0/0 + Router(config-if)#no shu + Router(config-if)#int f0/0.11 + Router(config-subif)#enc d 11 + Router(config-subif)#ip add 192.168.21.129 255.255.255.240 + Router(config-subif)#int f0/0.21 + Router(config-subif)#enc d 21 + Router(config-subif)#ip add 192.168.21.200 255.255.255.240 + Router(config-subif)#ex + Router(config)#int f0/1 + Router(config-if)#ip add 192.168.21.18 255.255.255.240 + Router(config-if)#no shu + Router(config-if)#ex + Router(config)#ro o 1 + Router(config-router)#net 192.168.21.16 0.0.0.15 a 0 + Router(config-router)#net 192.168.21.128 0.0.0.15 a 0 + Router(config-router)#net 192.168.21.192 0.0.0.15 a 0 + ``` + + ![image-20240510203659372](./imgs/05104.png) + + ![image-20240510203745078](./imgs/05105.png) \ No newline at end of file diff --git "a/43\346\236\227\346\200\241\347\220\264/imgs/05101.png" "b/43\346\236\227\346\200\241\347\220\264/imgs/05101.png" new file mode 100644 index 0000000000000000000000000000000000000000..22a518c26c2b3753724bd8597fca90d7f5f8a481 Binary files /dev/null and "b/43\346\236\227\346\200\241\347\220\264/imgs/05101.png" differ diff --git "a/43\346\236\227\346\200\241\347\220\264/imgs/05102.png" "b/43\346\236\227\346\200\241\347\220\264/imgs/05102.png" new file mode 100644 index 0000000000000000000000000000000000000000..5126565a69f4bdbc7b0fd1a6c8e2f92ff123f717 Binary files /dev/null and "b/43\346\236\227\346\200\241\347\220\264/imgs/05102.png" differ diff --git "a/43\346\236\227\346\200\241\347\220\264/imgs/05103.png" "b/43\346\236\227\346\200\241\347\220\264/imgs/05103.png" new file mode 100644 index 0000000000000000000000000000000000000000..62967020f129130893ebc6633b248c9078dd7471 Binary files /dev/null and "b/43\346\236\227\346\200\241\347\220\264/imgs/05103.png" differ diff --git "a/43\346\236\227\346\200\241\347\220\264/imgs/05104.png" "b/43\346\236\227\346\200\241\347\220\264/imgs/05104.png" new file mode 100644 index 0000000000000000000000000000000000000000..1b4be7b69b3f53bc3c95e518b6e36cacfb93d7db Binary files /dev/null and "b/43\346\236\227\346\200\241\347\220\264/imgs/05104.png" differ diff --git "a/43\346\236\227\346\200\241\347\220\264/imgs/05105.png" "b/43\346\236\227\346\200\241\347\220\264/imgs/05105.png" new file mode 100644 index 0000000000000000000000000000000000000000..7c6fe3751ed11723029aa3cc6014c477d1db095a Binary files /dev/null and "b/43\346\236\227\346\200\241\347\220\264/imgs/05105.png" differ diff --git "a/43\346\236\227\346\200\241\347\220\264/imgs/05106.png" "b/43\346\236\227\346\200\241\347\220\264/imgs/05106.png" new file mode 100644 index 0000000000000000000000000000000000000000..824ddf7187465cad0542aebd22c489c1df859db0 Binary files /dev/null and "b/43\346\236\227\346\200\241\347\220\264/imgs/05106.png" differ