From 51283598782dd9b90ae87fab74a967ee314e1b66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E7=9B=9F?= <3098697928@qq.com> Date: Sun, 5 May 2024 15:25:01 +0000 Subject: [PATCH 1/6] =?UTF-8?q?=E7=AC=94=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 蔡盟 <3098697928@qq.com> --- .../20240422\347\254\224\350\256\260.md" | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 "\350\224\241\347\233\237/20240422\347\254\224\350\256\260.md" diff --git "a/\350\224\241\347\233\237/20240422\347\254\224\350\256\260.md" "b/\350\224\241\347\233\237/20240422\347\254\224\350\256\260.md" new file mode 100644 index 0000000..367d383 --- /dev/null +++ "b/\350\224\241\347\233\237/20240422\347\254\224\350\256\260.md" @@ -0,0 +1,40 @@ +### 生成树协议STP + +先配置交换机的RSTP,再连接,如果先连线再配置会造成广播风暴,影响交换机的正常工作。 + +```bash +#四台pc机配置 +ip:192.168.1.2-5 + +#两台交换机的配置 +Switch>en +Switch#show spanning-tree //査看交换机生成树运行状态 +Switch#show spanning-tree summary //査看生成树的配置信息 + +Switch(config)#int f0/1 +Switch(config-if)#switchport access vlan 2 + +Switch(config)#int f0/2 +Switch(config-if)#switchport access vlan 3 + +Switch(config)#int ran f0/23-24 +Switch(config-if)#switch mode trunk + +Switch(config)#spanning-tree mode rapid-pvst //指定生成树协议的类型为RSTP + +Switch#show spanning-tree + + + +#测试 pc0 ping pc2 +ping 192.168.1.4 #能通 + +#进入一台交换机,关闭主链路上的端口 +Switch(config)#int f0/23 +Switch(config-if)#shutdown + +#再 pc0 ping pc2 +ping 192.168.1.4 #还是能通 + +#说明备份链路已启用 +``` -- Gitee From 611ae36cfc3ab62a991f5924b4a502eceaa3a5cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E7=9B=9F?= <3098697928@qq.com> Date: Sun, 5 May 2024 15:26:07 +0000 Subject: [PATCH 2/6] =?UTF-8?q?=E7=AC=94=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 蔡盟 <3098697928@qq.com> --- .../20240424\347\254\224\350\256\260.md" | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 "\350\224\241\347\233\237/20240424\347\254\224\350\256\260.md" diff --git "a/\350\224\241\347\233\237/20240424\347\254\224\350\256\260.md" "b/\350\224\241\347\233\237/20240424\347\254\224\350\256\260.md" new file mode 100644 index 0000000..034d136 --- /dev/null +++ "b/\350\224\241\347\233\237/20240424\347\254\224\350\256\260.md" @@ -0,0 +1,82 @@ +### 端口聚合配置 + ++ 作用 + + 提高链路带宽 + + 支持负载均衡 + + 提供链路备份 + + 防止网络环路 + +一台交换机只能有一个汇聚组,一个组最多有4个端口,端口必须是连续的(f 0/1-4) + +#### 步骤 + +1. 按拓扑图搭建网络,并为交换机提供冗余链路 + +2. 选择编号连续的端口进行配置 + +3. 将连续的多端口加入链路组并开启 + +4. 为聚合链路开启均衡负载功能 + +```bash +#Switch0和Switch1配置 +Switch(config)#int ran f0/23-24 +Switch(config-if-range)#switch mode trunk //将端口配置为trunk模式 +Switch(config-if-range)#channel-group 1 mode on //加入链路组1并开启 + +Switch(config)#port-channel load-balance dst-ip //按目的ip地址来实现负载均衡 + +Switch#show etherchannel summary //显示以太通道信息 + +Switch(config)#interface port-channel 1 //进入聚合端口的端口配置模式 + +Switch#show interfaces etherchannel //显示聚合端口信息 + +``` + + + +### 端口安全配置 + +#### 步骤 + +1. 开启交换机的端口安全功能 + +2. 配置交换机的最大连接数限制 + +3. 查看主机的IP和MAC地址信息 + +4. 配置交换机的地址绑定 + +5. 查看交换机上端口安全配置 + +```bash +# Switch0 配置 +Switch(config)#int ran f0/1-2 +Switch(config-if-range)#switchport mode access //配置端口为接入类型 +Switch(config-if-range)#switchport port-security //开启端口安全功能 + +# 设置端口最大连接数为1,即启用动态MAC安全地址 +Switch(config-if-range)#switchport port-security maximum 1 + +# 若发现违规动作,处理方式为关闭端口 +Switch(config-if-range)#switchport port-security violation shutdown +Switch(config-if-range)#end +Switch#show port-security //查看端口安全配置 +``` + +```bash +# Switch1 配置 + +Switch(config)#int ran f0/1-2 + +# 启用粘性MAC地址,自动绑定接入的MAC地址 +Switch(config-if-range)#switchport port-security mac-address sticky + +# ping测试,结果链路均通 +# 然后互换PC2和PC3在交换机上的端口,ping测试,结果链路均不通 + +Switch#show mac-address-table //查看端口MAC地址绑定配置 +Switch#clear port-security sticky //清除所有已绑定的粘性MAC地址 + +``` -- Gitee From 6d47a77a3f55d8d4371b5ec6e3a5ec7f3a687ff6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E7=9B=9F?= <3098697928@qq.com> Date: Sun, 5 May 2024 15:26:49 +0000 Subject: [PATCH 3/6] =?UTF-8?q?=E7=AC=94=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 蔡盟 <3098697928@qq.com> --- .../20240425\347\254\224\350\256\260.md" | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 "\350\224\241\347\233\237/20240425\347\254\224\350\256\260.md" diff --git "a/\350\224\241\347\233\237/20240425\347\254\224\350\256\260.md" "b/\350\224\241\347\233\237/20240425\347\254\224\350\256\260.md" new file mode 100644 index 0000000..286faf5 --- /dev/null +++ "b/\350\224\241\347\233\237/20240425\347\254\224\350\256\260.md" @@ -0,0 +1,57 @@ +### 三层交换机配置 + +```bash +Switch(config)#ip routing #开启路由功能 +Switch(config)#int f0/1 +Switch(config-if)#no switchport #将f0/1端口启用三层路由功能 +Switch(config-if)#ip address 192.168.1.1 255.255.255.0 #配置IP +Switch(config-if)#no shutdown #开启端口 +``` + + + +### 三层交换机配置VLAN + +```bash +# 二层交换机配置 +Switch(config)#vlan 2 //创建VLAN 2 +Switch(config)#vlan 3 //创建VLAN 3 + +Switch(config)#int f0/2 +Switch(config-if)#swi acc vlan 2 +Switch(config)#int f0/3 +Switch(config-if)#swi acc vlan 3 + +Switch(config)#inter f0/1 +Switch(config-if)#swi mode trunk //设置端口模式为Trunk +Switch(config-if)#end +Switch#show vlan //查看VLAN配置信息 +``` + +```bash +# 三层交换机配置 +Switch(config)#ip routing //开启路由功能 + +Switch(config)#vlan 2 //创建VLAN 2 +Switch(config)#vlan 3 //创建VLAN 3 + +Switch(config)#int f0/1 //配置交换机和三层交换机的连接端口 +#先将该接口的Trunk封装为802.1Q的帧格式,后再配置端口模式为Trunk +Switch(config-if)#switchport trunk encapsulation dot1q +Switch(config-if)#swi mode trunk + +Switch(config)#int f0/2 +Switch(config-if)#swi acc vlan 2 +Switch(config)#int f0/3 +Switch(config-if)#swi acc vlan 3 + +Switch(config)#int vlan 2 //进入SVI接口模式 +Switch(config-if)#ip address 192.168.1.1 255.255.255.0 +Switch(config-if)#no shutdown //端口默认打开 + +Switch(config)#int vlan 3 +Switch(config-if)#ip address 192.168.2.1 255.255.255.0 +Switch(config-if)#no shutdown + +Switch#show ip route //查看路由表 +``` -- Gitee From 2a40394ac7062669bb668d5e976644416a16500e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E7=9B=9F?= <3098697928@qq.com> Date: Sun, 5 May 2024 15:27:27 +0000 Subject: [PATCH 4/6] =?UTF-8?q?=E7=AC=94=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 蔡盟 <3098697928@qq.com> --- .../20240426\347\254\224\350\256\260.md" | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 "\350\224\241\347\233\237/20240426\347\254\224\350\256\260.md" diff --git "a/\350\224\241\347\233\237/20240426\347\254\224\350\256\260.md" "b/\350\224\241\347\233\237/20240426\347\254\224\350\256\260.md" new file mode 100644 index 0000000..35042a9 --- /dev/null +++ "b/\350\224\241\347\233\237/20240426\347\254\224\350\256\260.md" @@ -0,0 +1,55 @@ +### 路由器SSH配置 + +```bash +# 1.基本配置 +Router>en +Router#conf t +Router(config)#host R1 +R1(config)#int f0/0 //进入路由器端口并打开 +R1(config-if)#no shutdown +R1(config-if)#ip add 192.168.10.1 255.255.255.0 +R1(config-if)#exit + +# 2.设置域名 +R1(config)#ip domain-name ssh + +# 3.生成密钥 +R1(config)#crypto key generate rsa +How many bits in the modulus [512]: 2048 //1024-2048 越大越优先 + +# 4.开启ssh服务 +R1(config)#ip ssh v 2 +R1(config)#line vty 0 4 +R1(config-line)#login local //本地用户登录 +R1(config-line)#transport input ssh //登入模式为ssh登录 +R1(config-line)#exit + +# 5.设置特权密码及用户和密码 +R1(config)#enable pass 555 +R1(config)#username ssh password 666 + +# 6.保存 +R1(config)#do wr m +Building configuration... +[OK] +``` + +### 路由器Telnet配置 + +```bash +# 基本配置 +Router>en +Router#conf t +Router(config)#host R1 +R1(config)#int f0/0 //进入路由器端口并打开 +R1(config-if)#no shutdown +R1(config-if)#ip add 192.168.10.1 255.255.255.0 +R1(config-if)#exit + +#telnet配置 +R1(config)#enable pass 555 //设置特权密码 +R1(config)#line vty 0 4 +R1(config-line)#password 666 //设置Telnet登录密码 +R1(config-line)#login //启用密码认证 +R1(config-line)#exit +``` -- Gitee From 5b1ffd5cc20651d97485d108fadcda9677c18af5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E7=9B=9F?= <3098697928@qq.com> Date: Sun, 5 May 2024 15:28:27 +0000 Subject: [PATCH 5/6] =?UTF-8?q?=E7=AC=94=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 蔡盟 <3098697928@qq.com> --- .../20240428\347\254\224\350\256\260.md" | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 "\350\224\241\347\233\237/20240428\347\254\224\350\256\260.md" diff --git "a/\350\224\241\347\233\237/20240428\347\254\224\350\256\260.md" "b/\350\224\241\347\233\237/20240428\347\254\224\350\256\260.md" new file mode 100644 index 0000000..3dfe826 --- /dev/null +++ "b/\350\224\241\347\233\237/20240428\347\254\224\350\256\260.md" @@ -0,0 +1,34 @@ +### 单臂路由 + +设备:一台路由器 一台交换机 四台PC机 + +```bash +#交换机配置 +Switch(config)#host sw1 +sw1(config)#vlan 2 +sw1(config)#vlan 3 + +sw1(config)#int ran f0/1-2 +sw1(config-if-range)#swi acc vlan 2 + +sw1(config)#int ran f0/3-4 +sw1(config-if-range)#swi ac vlan 3 + +sw1(config)#int f0/24 +sw1(config-if)#swi mode trunk +``` + +```bash +#路由器配置 +Router(config)#host r1 +r1(config)#int f0/0 //进入路由器0模块第0端口并开启 +r1(config-if)#no shutdown + +r1(config)#int f0/0.1 //进入路由器0模块第0端口第1虚拟子接口 +r1(config-subif)#encapsulation dot1Q 2 //封装协议设置为dot1Q 允许通过的vlan为2 +r1(config-subif)#ip add 192.168.10.1 255.255.255.0 //设置子接口ip + +r1(config)#int f0/0.2 //进入路由器0模块第0端口第2虚拟子接口 +r1(config-subif)#encapsulation dot1Q 3 //封装协议设置为dot1Q 允许通过的vlan为3 +r1(config-subif)#ip add 192.168.20.1 255.255.255.0 //设置子接口ip +``` -- Gitee From 01776a179a527988354c56ad1474dc8b9364d91a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E7=9B=9F?= <3098697928@qq.com> Date: Sun, 5 May 2024 15:29:05 +0000 Subject: [PATCH 6/6] =?UTF-8?q?=E7=AC=94=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 蔡盟 <3098697928@qq.com> --- .../20240429\347\254\224\350\256\260.md" | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 "\350\224\241\347\233\237/20240429\347\254\224\350\256\260.md" diff --git "a/\350\224\241\347\233\237/20240429\347\254\224\350\256\260.md" "b/\350\224\241\347\233\237/20240429\347\254\224\350\256\260.md" new file mode 100644 index 0000000..18bb7e5 --- /dev/null +++ "b/\350\224\241\347\233\237/20240429\347\254\224\350\256\260.md" @@ -0,0 +1,37 @@ +### 静态路由配置 + +设备:两台路由器 一台交换机 三台pc + +```bash +# 第一台路由器 +Router(config)#host r1 +r1(config)#int f0/0 //设置路由器到交换机接口的IP地址 +r1(config-if)#ip add 192.168.10.1 255.255.255.0 +r1(config-if)#no sh //启用端口 + +r1(config)#int s2/0 //设置路由器到路由器接口的IP地址 +r1(config-if)#ip add 192.168.30.2 255.255.255.0 +r1(config-if)#clock rate 64000 //设置时钟频率 +r1(config-if)#no sh + +# 设置路由转发表 ip route 目的地址 目的地址子网掩码 下一跳地址 +r1(config)#ip route 192.168.20.0 255.255.255.0 192.168.30.3 + +``` + +```bash +# 第二台路由器 +Router(config)#host r2 +r2(config)#int f0/0 //设置路由器到pc机接口的IP地址 +r2(config-if)#ip add 192.168.20.1 255.255.255.0 +r2(config-if)#no sh //启用端口 + +r2(config)#int s2/0 //设置路由器到路由器接口的IP地址 +r2(config-if)#ip add 192.168.30.3 255.255.255.0 +r2(config-if)#clock rate 64000 //设置时钟频率 +r2(config-if)#no sh + +# 设置路由转发表 ip route 目的地址 目的地址子网掩码 下一跳地址 +r2(config)#ip route 192.168.10.0 255.255.255.0 192.168.30.2 + +``` -- Gitee