常用运维安全命令

张开发
2026/4/21 14:34:45 15 分钟阅读

分享文章

常用运维安全命令
各平台下所输入命令及其代表含义交换机通过后方console口输入命令实际工作中交换机设备如何进行配置交换机实际设备后方的结构中上面有一个console口这个就是对交换机进行配置命令的一个端口使用console线一端连接交换机console口另一端连接计算机USB或com计算机安装puttysecureCRTXshell等终端程序软件进入设备的配置界面。以华为交换机为例HuaweiSystem-view 进入系统视图[Huawei]Interface GigabitEthernet 0/0/1 选择交换机0/0/1接口[Huawei-GigabitEthernet0/0/1]接口视图quit 退回到上一个视图逐级退回[Huawei-GigabitEthernet0/0/1]quit[Huawei]quitReturn 或者快捷键ctrlz直接退回到用户视图[Huawei-GigabitEthernet0/0/1]returnHuaweidisplay version 查看版本信息Huaweidisplay versiondisplay current-configuration查看当前有效配置Huaweidisplay current-configurationdisplay this查看当前视图的有效配置[Huawei]interface GigabitEthernet 0/0/1[Huawei-GigabitEthernet0/0/1]display thissysname 更改设备名Huaweisystem-view[Huawei]sysname sw1 修改设备名为sw1save 保存配置sw1savereboot 重启sw1reboot执行时会有两次询问一个是是否保存一个是是否重启重启会产生提示选择n再输入reboot save diagnostic-information就可以保存shutdown 禁用接口undo shutdown 启用接口[Huawei]interface GigabitEthernet 0/0/2[Huawei-GigabitEthernet0/0/2]shutdown 禁用接口[Huawei-GigabitEthernet0/0/2]undo shutdown 启用接口通过控制口console设置密码[sw1]user-interface console 0 //进入终端进行配置console只有一个口0[sw1-ui -console0]authentication-mode password //启用密码认证[sw1-ui-console0]set authentication password cipher 123456 //设置终端密码为123456密文取消本地访问口令取消密码[sw1-ui-console0]undo authentication-mode password //取消密码认证设置交换机闲置会话时间[sw1]user-interface console 0 //进终端进行配置[sw1-ui-console0]idle -timeout 1 //设置闲置会话时间为1分钟[sw1-ui-console0]idle-timeout 0 //设置时间为永不超时学习用[sw1-ui-console0]idle-timeout 1440//设置时间为24小时工作用取消/开启终端提示取消/开启闲置会话的显示sw1undo terminal monitor //取消闲置会话的显示sw1 terminal monitor //开启闲置会话的显示快捷设置是u t m初始化sw1reset saved-configuration //恢复出场设置以上详见阶段一 基础篇二给交换机配置管理IP给交换机配置IP地址也是通过交换机后方console口进行设置进入Vlan1的虚接口物理意义上设备后方没有这个插口[Huawei]interface Vlanif 1 //Vlan1虚接口[Huawei-Vlanif1]ip address 192.168.1.100 255.255.255.0 //自定义设置vlan1接口地址Huaweidisplay vlan 查看vlan虚接口telnet 远程管理协议交换机客户端发起telnet远程管理Telnet 目标IP第一台交换机LSW1//给交换机lsw1配置网络位[lsw1]interface Vlanif 1[lsw1-Vlanif1]ip address 192.168.1.252 24 //255.255.255.0是24个网络位后面输入24即可[lsw1]user-interface vty 0 4 //设置远程管理终端个数 //允许对终端进行访问的管理个数0到4一共5个[lsw1-ui-vty0-4]authentication-mode password //启用认证方式为密码认证[lsw1-ui-vty0-4]set authentication password cipher Taren1 //设置终端密码Taren1[lsw1-ui-vty0-4]user privilege level 3 //给到第3等级的管理员权限//设置权限级别权限等级分为0-15默认为权限0参观级其中3之后就是管理员权限第二台交换机LSW2扮演管理员PC计算机的角色正常情况下在pc的命令行输入命令//给交换机lsw2配置网络位[lsw2]interface Vlanif 1[lsw2-Vlanif1]ip address 192.168.1.251 24lsw2telnet 192.168.1.252telnet成功也需要电脑的网线与交换机相连只是不需要再在console口处进行设置阶段一 基础篇三查看MAC地址表Huaweidisplay mac-address创建vlanHuaweisystem-view[Huawei]vlan 2[Huawei-vlan2]quit[Huawei]quit最多可以创建到4094个vlan接口删除vlanHuaweisystem-view[Huawei]undo vlan 2创建多个vlan、删除多个vlan[Huawei]vlan batch 10 20 30 创建多个不连续的vlan[Huawei]vlan batch 10 to 20 创建多个连续的vlan[Huawei]undo vlan batch 10 20 30 删除多个不连续vlan[Huawei]undo vlan batch 10 to 20 删除多个连续的vlan端口加入vlanHuaweisystem-view[Huawei]vlan 2 //创建vlan2[Huawei]interface GigabitEthernet 0/0/1[Huawei-GigabitEthernet0/0/1]port link-type access //接口模式配置为access模式[Huawei-GigabitEthernet0/0/1]port default vlan 2 //接口1加入vlan2[Huawei-GigabitEthernet0/0/1]return这也是vlan主要作用之一分割广播域阶段一 基础篇十三路由器通过后方console口输入命令不同网段pc连接pc交换机路由器设置路由器与交换机一样后方有console口路由器接线端口ip地址即网关根据实际网段设置不同网段pc必须设置对应网关这种形式就是典型的直连路由详见阶段一 基础篇三R1display ip routing-table //查看路由表对路由器设置远程管理路由器端[ar1]interface GigabitEthernet 0/0/0 //选择了接口0/0/0[ar1-GigabitEthernet0/0/0]ip address 192.168.1.252 24 //接口地址[ar1]user-interface vty 0 4 //vty远程管理可登录用户个数5[ar1-ui-vty0-4]authentication-mode password //设置认证密码模式Please configure the login password (maximum length 16):Taren1[ar1-ui-vty0-4]set authentication password cipher Taren1 //密码设为Taren1[ar1-ui-vty0-4]user privilege level 3 //设置权限等级3pc端PCtelnet 192.168.1.252windows下cmd命令windows下运行命令

更多文章