From 9ad2e9099de171b633045a25a0d720bf15310a87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A6=E5=8A=9B=E8=8E=89?= <2923443262@qq.com> Date: Tue, 1 Apr 2025 12:17:35 +0800 Subject: [PATCH 1/2] 1 --- ...11\345\205\250\347\256\241\347\220\206.md" | 173 ++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 "13 \351\237\246\345\212\233\350\216\211/20250331\344\272\244\346\215\242\346\234\272\345\256\211\345\205\250\347\256\241\347\220\206.md" diff --git "a/13 \351\237\246\345\212\233\350\216\211/20250331\344\272\244\346\215\242\346\234\272\345\256\211\345\205\250\347\256\241\347\220\206.md" "b/13 \351\237\246\345\212\233\350\216\211/20250331\344\272\244\346\215\242\346\234\272\345\256\211\345\205\250\347\256\241\347\220\206.md" new file mode 100644 index 0000000..c96e122 --- /dev/null +++ "b/13 \351\237\246\345\212\233\350\216\211/20250331\344\272\244\346\215\242\346\234\272\345\256\211\345\205\250\347\256\241\347\220\206.md" @@ -0,0 +1,173 @@ + # 一、Console密码配置 + +```cmd +Switch> enable //进入特权执行模式,获得设备高级操作权限 +Switch# configure terminal //进入全局配置模式,影响整个设备的配置参数 +Switch(config)# line console 0 //控制台线路模式,"0"表示第一个控制台接口 +Switch(config-line)# password abc123456 //设置控制台登录密码为"abc123456" +Switch(config-line)# login //强制连接控制台时输入密码,若不配置不会生效 +Switch(config-line)# end //直接退出所有配置模式,返回特权执行模式 +Switch# show running-config //显示配置文件内容,用来检查配置是否生效, 特权模式 +Switch# write //保存配置 +``` + +![img](https://gitee.com/gcxxl/note-sheet-bed/raw/master/images/202503311405255.png) + +![img](https://gitee.com/gcxxl/note-sheet-bed/raw/master/images/202503311405285.png) + +启用全局密码加密服务 + +```cmd +Swich(config)# service password-encryption +``` + +![image-20250331140739220](https://gitee.com/gcxxl/note-sheet-bed/raw/master/images/202503311407246.png) + +# 二、Telnet配置 + +```cmd +Switch> +Switch>enable +Switch#configure terminal +Switch(config)#line vty 0 4 /进入虚拟终端线路配置模式(0-4表示5个并发远程连接) +Switch(config-line)#password 112233 //设置Telnet登录密码 +Switch(config-line)#login //启用密码验证(必须配置才能使密码生效) +Switch(config-line)#transport input telnet //指定这些线路只接受Telnet连接 +Switch(config-line)#exit //退出当前配置模式(返回上一级) +Switch(config)#interface vlan 1 //进入VLAN 1接口配置模式(默认管理VLAN) +Switch(config-if)#ip address 192.168.10.1 255.255.255.0 //为交换机设置管理IP地址和子网掩码 +Switch(config-if)#no shutdown //激活该虚拟接口(默认交换机物理接口常开,但VLAN接口需手动激活) +``` + +![image-20250331142859532](https://gitee.com/gcxxl/note-sheet-bed/raw/master/images/202503311428558.png) + +![image-20250331230313263](https://gitee.com/gcxxl/note-sheet-bed/raw/master/images/202503312303293.png) + +![image-20250331231256636](https://gitee.com/gcxxl/note-sheet-bed/raw/master/images/202503312312693.png) + +对特权模式进行密码配置 + +```cmd +#特权模式有两种密码 +Switch(config)# enable password 111111 //明文密码 +Switch(config)#end +Switch#show running-config | include enable //可见密码被暴露 +Switch(config) +# enable secret 222222 //加密密码 +Switch#show running-config | include enable //可见密码被加密 +``` + +![image-20250331233417139](https://gitee.com/gcxxl/note-sheet-bed/raw/master/images/202503312334161.png) + +# 三、SSH高级配置 + +```cmd +Switch(config)# hostname SW1 //主机名(RSA密钥生成必需) +SW1(config)# ip domain-name mxdx.com //域名(RSA密钥生成必需) +SW1(config)# crypto key generate rsa //生成RSA密钥,可直接回车 +SW1(config)# username admin secret abc //创建本地用户admin,密码abc(SSH登录用) +SW1(config)# line vty 0 4 +SW1(config-line)# transport input ssh //只允许SSH +SW1(config-line)# login local //使用本地用户认证 +SW1# show ip ssh //确认SSH已启用 +``` + +![image-20250331235234388](https://gitee.com/gcxxl/note-sheet-bed/raw/master/images/202503312352469.png) + +1. 如何同时开启SSH和Telnet + + 1. **进入全局配置模式** + + ``` + enable + configure terminal + ``` + + 2. **配置VTY线路(Telnet & SSH)** + + ``` + line vty 0 4 # 允许5个并发会话(0-4) + password Telnet@Pass # 设置Telnet密码(明文) + login local # 启用本地认证(可选,更安全) + transport input ssh telnet # 同时允许SSH和Telnet + exit + ``` + + 3. **配置SSH(必须步骤)** + + ``` + ! 设置主机名和域名(SSH必需) + hostname RouterSSH + ip domain-name example.com + + ! 生成RSA密钥(SSH必需) + crypto key generate rsa + ! 建议密钥长度2048位: + crypto key generate rsa modulus 2048 + + ! 启用SSH v2(更安全) + ip ssh version 2 + ``` + + 4. **创建本地用户(可选,替代明文密码)** + + ``` + username admin secret Ssh@Pass123 # 加密存储 + ``` + + 5. **验证配置** + + ``` + show ip ssh # 检查SSH状态 + show line vty 0 # 查看VTY线路配置 + ``` + + ------ + + ### **2. 如何反向操作(取消密码、取消登录)** + + #### **(1) 取消Telnet(仅保留SSH)** + + ``` + line vty 0 4 + no transport input telnet # 禁用Telnet,仅允许SSH + exit + ``` + + #### **(2) 完全禁用Telnet** + + ``` + line vty 0 4 + no transport input # 禁用所有远程登录(需Console恢复) + exit + ``` + + #### **(3) 取消Console密码** + + ``` + line console 0 + no password # 删除密码 + no login # 取消登录认证 + exit + ``` + + #### **(4) 取消SSH服务** + + ``` + no ip ssh server # 关闭SSH服务 + crypto key zeroize rsa # 删除RSA密钥 + ``` + + #### **(5) 取消特权密码(enable密码)** + + ``` + no enable secret # 删除加密的特权密码 + ``` + + #### **(6) 取消本地用户认证** + + ``` + no username admin # 删除本地用户 + ``` + + \ No newline at end of file -- Gitee From 4616ccd1a3bfcf4201b072bc2fd65e2c57b7f09e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A6=E5=8A=9B=E8=8E=89?= <2923443262@qq.com> Date: Wed, 2 Apr 2025 21:36:49 +0800 Subject: [PATCH 2/2] 1 --- ...46\234\272VLAN\351\205\215\347\275\256.md" | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 "13 \351\237\246\345\212\233\350\216\211/20250401\344\272\244\346\215\242\346\234\272VLAN\351\205\215\347\275\256.md" diff --git "a/13 \351\237\246\345\212\233\350\216\211/20250401\344\272\244\346\215\242\346\234\272VLAN\351\205\215\347\275\256.md" "b/13 \351\237\246\345\212\233\350\216\211/20250401\344\272\244\346\215\242\346\234\272VLAN\351\205\215\347\275\256.md" new file mode 100644 index 0000000..cf78fc8 --- /dev/null +++ "b/13 \351\237\246\345\212\233\350\216\211/20250401\344\272\244\346\215\242\346\234\272VLAN\351\205\215\347\275\256.md" @@ -0,0 +1,88 @@ +#### 1.检测第一模块PC机是否互通 + +![image-20250402190926810](https://gitee.com/Wll_xw/picture-bed-01/raw/master/img/upgit_20250402_1743592167.png) + +**只有同一个VLAN编号内的主机 ,才可以互相通讯,言外之意不同VLAN编号,不能通讯** + +![image-20250402190958902](https://gitee.com/Wll_xw/picture-bed-01/raw/master/img/upgit_20250402_1743592199.png) + +#### 2.将一个普通局域网分割成三个虚拟局域网,vlan10,vlan20,vlan30,所以要设置交换机,将不同的接口划分到对应的VLAN编号, + +#### **创建相对应的vlanID: 10 20 30** + +``` +Switch(config)#vlan 10 +Switch(config-vlan)#exit +Switch(config)#vlan 20 +Switch(config-vlan)#exit +Switch(config)#vlan 30 +Switch(config-vlan)#exit + + + +``` + +#### 3.选择对应的接口,划入对应的VLAN编号 + +``` +# 单接口 +Switch(config)#interface fastEthernet 0/1 // 选择一个接口 +Switch(config-if)#switchport access vlan 10 //将接口划入VLAN10 ,access模式用来连接网络设备和主机电脑 + +# 连续的多接口 +Switch(config)#interface range f0/2-3 // 连续的2到3 +Switch(config-if-range)#switchport access vlan 10 +``` + +![image-20250402201024060](https://gitee.com/Wll_xw/picture-bed-01/raw/master/img/upgit_20250402_1743595824.png) + +![image-20250402202029698](https://gitee.com/Wll_xw/picture-bed-01/raw/master/img/upgit_20250402_1743596429.png) + +![image-20250402202049023](https://gitee.com/Wll_xw/picture-bed-01/raw/master/img/upgit_20250402_1743596449.png) + +#### 4.**如果VLAN10不通VLAN20和30则隔离成功** + +![image-20250402202700756](https://gitee.com/Wll_xw/picture-bed-01/raw/master/img/upgit_20250402_1743596821.png) + +![image-20250402202728600](https://gitee.com/Wll_xw/picture-bed-01/raw/master/img/upgit_20250402_1743596848.png) + +#### 更改VLAN名字 + +![image-20250402203042628](https://gitee.com/Wll_xw/picture-bed-01/raw/master/img/upgit_20250402_1743597042.png) + +``` +# 给vlan改名字,默认是VALN0020 +Switch(config)#vlan 20 +Switch(config-vlan)#name students +``` + +#### 5.让交换机互通 + +![image-20250402203910501](https://gitee.com/Wll_xw/picture-bed-01/raw/master/img/upgit_20250402_1743597550.png) + +#### 5.1 将两者23接口归为VLAN30 + +![image-20250402204528848](https://gitee.com/Wll_xw/picture-bed-01/raw/master/img/upgit_20250402_1743597928.png) + +![image-20250402204826123](https://gitee.com/Wll_xw/picture-bed-01/raw/master/img/upgit_20250402_1743598106.png) + +![image-20250402212721430](https://gitee.com/Wll_xw/picture-bed-01/raw/master/img/upgit_20250402_1743600442.png) + +#### 6.把交换机之间的线变为共享 + +``` +Switch(config-if)#switchport mode trunk + + +# 或者 查看所有接口的信息 +Switch#show interfaces status + + +SW3#show interfaces status +``` + +![image-20250402213026212](https://gitee.com/Wll_xw/picture-bed-01/raw/master/img/upgit_20250402_1743600626.png) + +#### 如果两方的VLAN10 20 30分别ping成功则连接成功 + +![image-20250402213254066](https://gitee.com/Wll_xw/picture-bed-01/raw/master/img/upgit_20250402_1743600774.png) \ No newline at end of file -- Gitee