侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

Cisco交换机与路由器命令总结

2023-02-13 星期一 / 0 评论 / 0 点赞 / 68 阅读 / 17671 字

1.查看信息showversion查看版本及引导信息showrunning-config查看运行设置showstartup-config查看开机设置showinterfaceg0/1显示端口信息sho

.

1.查看信息

show version    查看版本及引导信息  show running-config     查看运行设置  show startup-config     查看开机设置  show interface g0/1     显示端口信息  show ip router      显示路由信息  show clock      查看系统时钟  show log        查看日志  show interface counters     查看接口流量  show interface description  查看端口的连接状态与描述   show interface status  查看端口的链接状态、所属vlan以及速率双工show cdp neighbors  查看CDP邻居   show processes cpu  查看设备CPU使用率    show vlan br    查看vlan数据库    show ip int brief //查看所有端口状况 show int des    //查看所有端口的描述 show int f0/1   //查看f0/1接口状态 show run int f0/1    //查看f0/1配置状况 show run int valn 180    //查看Vlan 的配置状态 show vtp stauts  //查看vtp 的状态 show clock       //查看交换机当前的时间 show ntp stauts     //查看ntp 是否同步show ip ssh  //查看SSH配置


2.设置console登录的密码 

(confing)#line console 0 (config-line)#password 123 (config-line)#login

3.设置进入特权模式的密码 

(config)#enable password abc (config)#login  或者(config)#enable secret 456 (config)#login


4.设置远程登入(telnet)的密码(登入后,如需进入特权模式,还需要设置进入特权模式的密码) 

(config)#line vty 0 4 (config-line)#password 789 (config-lline)#login 说明:在全局配置模式下使用service password-encryption命令加密明文的口令write保存设置

5.Cisco路由器与交换机口令恢复

#路由器的密码恢复:1)重启路由器,并同时按下Ctrl+breack键中断IOS的加载,进入ROM monitor模式2)将配置寄存器的值改为0x2142原值为0X2102,表示启动时忽略startup的配置Rommom>confreg 0X2142Rommom>reset3)路由器将重启,将无法加载配置文件因此不会有登录密码4)进入配置模式后,将配置文件手动加载回来Router#copy startup-config running-config5)通过show run命令查看路由器配置的密码,更改密码6)修改配置寄存器的值,并保持配置Router(config)#config-register 0x2102Router(config)#exitRouter#copy running-config startup-config#交换机的密码恢复:1)拔掉交换机的电源插头2)重新插好电源后,立即按住交换机上的mode键,当看到配置界面显示“switch”命令提示,松开”mode”键。进入故障恢复的简单IOS模式3)使用命令“Flash_init”初始化Flash4)将config,text文件名改成config.oldSwitch:rename flash:config.text flash:config.old5)重启交换机时将不会加载配置文件Switch:boot6)把配置文件的名字改回来Switch#rename flash:config.old flash:config.text7)手工加载配置文件Switch#copy flash:config.text system:running-config8)配置文件加载完成后,需要进入配置模式修改密码,最后保存配置,完成密码的恢复


6.常用的专用命令:

Switch(config)#no ip domain-lookup //禁用域名解析witch(config)#line console 0            //进入控制台接口Switch(config-line)#logging synchronous //使日志同步 Switch(config-line)#exec-timeout 0 0    //永不超时退出 (0分0秒)

7.全局设置

进入全局模式:  config terminal设置交换机名称:     hostname hostname设置访问用户及密码:  username username password password设置特权密码密文:  enable secret password设置将明文密码加密:  service password-encryption设置路由器名:  hostname name设置静态路由:  ip route destination subnet-mask next-hop启动IP路由:  ip routing启动IPX路由:  ipx routing端口设置:  interface type slot/number设置IP地址:  ip address address subnet-mask设置IPX网络:  ipx network network激活端口:  no shutdown物理线路设置:  line type number启动登录进程:  login [local|tacacs server]设置登录密码:  password password设置log存放路径:   logging 10.0.0.1                   spanning-tree mode rapid_pvst建立静态路由  ip route prefix mask {address | interface} [distance] [tag tag] [permanent]Prefix :所要到达的目的网络mask   :子网掩码address :下一个跳的IP地址,即相邻路由器的端口地址。interface  :本地网络接口distance :管理距离(可选)tag tag :tag值(可选)permanent :指定此路由即使该端口关掉也不被移掉。设置管理IP地址int vlan 1 ip address 192.168.1.251 255.255.255.0 // ip default-gateway 192.168.1.254 //设置默认路由,供其他网段访问

8.恢复出厂设置

en  erase startup-config delete flash:vlan.dat reload 重启


9.设置errdisable

(config)#errdisable recovery cause all //开启errdiable 恢复的原因 (config)#errdisable recovery interval 300 //errdisable后300秒恢复

10.SNMP服务配置:

enableconfigure terminalsnmp-server community PJY ro   设置陷阱只读snmp-server community PJY rwsnmp-server enable trapssnmp-server enable traps snmp authentication 启用陷阱snmp-server host 10.0.0.10 traps trapbhodc  指定snmp接受者snmp-server host 10.254.190.1 rw 配置网关工作站地址


11.VTP配置:

vpt domain pjy创建VTP域vtp mode {server|client|transparent}配置交换机VTP模式为,服务模式;客户端模式;透明模式vtp password配置VTP口令vtp pruning 配置VTP修剪vtp version 2配置VTP版本号show vtp status查看VTP配置信息show vlan brief查看vlan信息


12.vlan配置

vlan 10创建vlan 10name hehe命名vlan 10为heheno vlan 10  删除vlan 10int f0/1switchport mode access  设置接口为接入模式或(trunk)干道中继模式seitchport access vlan 10 将接口加入到vlan 10中default interface interface-id  还原接口默认配置switchport trunk encapsulation dot1q配置接口封装类型为dot1qswitchport native vlan 10show vlan brief查看vlan 信息show vlan id 10 查看vlan 10的详细信息多端口划分 int range f0/1 – 24 //端口范围为1-24 #sw mode access #sw ac vlan 180


13.端口配置

interface FastEthernet0/1 switchport access vlan 33 // 划分VLAN switchport mode access //接入模式switchport port-security maximum 2 //设定端口只允许接入2个PC switchport port-security // 启用端口安全 switchport port-security violation restrict // 发生违例 端口进errdisable,并记录 storm-control broadcast level 0.80 //控制广播包的突发百分比 storm-control action shutdown //暴风控制的违例时端口进入errdisable storm-control action trap //产生snmp trap(抑制)消息来通告发生过量流量的情况 spanning-tree portfast // 配置接口为portfast快速模式 spanning-tree bpduguard enable // 启用bpuguard 防护 spanning-tree guard root // 启用根桥防护


14.设置时间与同步

开启debug与log记录时间的服务 Service timestamps debug datetime localtime //开启debug记录时显示的时间 Service timestamps log datetime localtime //开启log记录时显示的时间 设置时间与时区 Clock timezone TAIWAN 8 //设置时区 Clock set 12:16:50 nov 27 2008 //设置时间(月,日,年) #Show clock //查看交换机当前的时间 设置ntp server 实现时间同步 ntp server 10.1.71.249 //设置交换机与ntp server 实现时间同步 #show ntp stauts //查看交换机是否同步


15.DHCP配置:

ip dhcp pool pjy定义ip地址池network 192.168.1.0 255.255.255.0定义IP地址段default-router192.168.1.1设定网关地址dns-server 202.106.0.20 为客户端配置DNS地址,可接多个,用空格隔开lease 1设定地址的租期ip dhcp excluded-address 192.168.1.50,192.168.1.60预留静态分配的IP地址


16.三层交换配置:

ip routing  启用路由功能interface vlan 10ip address 1.1.1.1 255.0.0.0配置虚接口IPno shutdown启动虚接口no switchpport 将三成接口转换为三层接口ip helper-address 192.168.1.100 配置中继DHCP服务器


17.ssh配置:

enconfig thostname zhang  //配置主机名ip domain-name pjy.cn  //配置域名aaa new-model  //配置AAA认证username pjycm secret [email protected]  //登陆用户名与密码crypto key generate rsa  //生成密钥wrip ssh time-out 120  //配置超时限定ip ssh authentication-retries 5  //配置错误密码重试次数配置登陆权限:line vty 0 4login local  #本地验证登陆transport input SSH  #只允许使用SSH登陆exit配置登陆IP:config tint vlan 1ip add 1.1.1.1 255.255.255.0no shaccess-list 90 remark Hosts allowed to SSH inaccess-list 90 permit 10.10.1.100 access-list 90 permit 10.10.1.101//指定可以用SSH登陆的主机源地址access-class 90 in //只允许指定源主机登录

18.STP生成树协议配置:

#spanning-tree vlan vlan-list启用生成树命令spanning-tree vlan vlan-list priority Bridge-priority指定根网桥spanning-tree vlan vlan-list root { primary | secondary }spanning-tree vlan vlan-list cost cost修改端口成本spanning-tree vlan vlan-list port-priority priority修改端口优先级spanning-tree portfast配置速端口#show spanning-tree查看生成树的配置#show spanning-tree vlan vlan-id detail查看某个VLAN的生成树详细信息


19.配置HSRP热备份路由选择协议:

R5(config)#inter vlan 10R5(config-if)#standby 2 ip 192.168.10.1  虚拟ip地址R5(config-if)#standby 2 preempt   配置占先权R5(config-if)#standby 2 priority 150   优先级R5(config-if)#standby 2 track fastEthernet 1/0   跟踪口R5(config-if)#standby 2 track fastEthernet 1/1R5(config-if)#inter vlan 20R5(config-if)#standby 3 ip 192.168.20.1  配置 vlan20的 虚拟网关R5(config-if)#standby 3 preempt   配置占先权R5(config-if)#standby 3 priority 145  优先级R5(config-if)#exR5(config)#inter f1/1  R5(config-if)#switchport mode trunk   中继口R5(config-if)#switchport trunk encapsulation dot1qR5(config)#spanning-tree vlan 10 root primary   负载均衡R5(config)#spanning-tree vlan 20 root secondary


路由器:

20.复用路由器外部接口地址:

Router(config)#access-list 1 permit 192.168.100.0 0.0.0.255Router(config)#ip nat inside source list 1 int f0/1 Router(config)#int f0/0Router(config-if)#ip nat inside Router(config)#int f0/1Router(config-if)#ip nat outside


21.查看NAT配置

Router#show ip nat translations Router#show ip nat statistics Router#show ip nat translations verbose 动态条目的保存时间:默认 USP 5分钟  DNS 1分钟  TCP 24小时 结束和复位(TCP的链接的结束和复位包) 1分钟 Router(config)#ip nat translation  dns-timeout 30  /icmp/tcp/udp/finrst/syn  seconds/neverRouter(config)#clear ip nat translation  *Router(config)#clear ip nat translation inside 192.168.1.1 162.152.8.8 Router(config)#clear ip nat translation outside 192.168.1.1 162.152.8.8 Router#debug ip nat Router(config)#ip nat translation tcp-timeout 500 Router(config)#ip nat translation udp-timeout 30 Router(config)#ip nat translation dns-timeout 30 Router(config)#ip nat translation icmp-timeout 30 Router(config)#ip nat translation finrst-timeout 30 Router(config)#ip nat translation syn-timeout 30 Router#show ip nat translation Router#clear ip nat translation * Router#clear ip nat translation inside 172.18.3.2 Router#clear ip nat translation outside 192.168.1.10 Router#show ip nat statistics Router#clear ip nat statisticsip nat inside source static tcp 192.168.1.2 80 211.82.20.129 80  //定义web服务器的静态端口转换


22.备份与恢复

#通过TFTP升级cisco路由和交换设备ISOcopy tftp flash#备份ISOcopy flash: tftp#备份配置文件copy running-config tftp#恢复配置文件copy tftp running-config


23.ACL访问控制列表

#标准访问控制列表建立:access-list 1 permit/deny 192.168.1.0 0.0.0.255  #建立控制列表ip access-group 1 in/out   #将acl应用到接口no access-list 1   #删除ACL控制列表no ip access-group 1 in/out  #取消接口上的ACL应用#扩展访问控制列表access-list 101 tcp 192.168.1.0 0.0.0.255 host 10.0.0.1 eq 80ip access-group 101 in/out #应用到接口no access-list 101 #删除ACLno ip access-group 101 in/out #取消接口上的ACL应用#命名访问控制列表ip access-list standard/extended  test1 permit/deny ip host 192.168.0.1 host 10.0.1.1 eq 3306no access-group standard/extended test  #删除整个ACL组no 10   #删除组中单一的语句show access-lists  #查看ACL

 

待补充......

.

广告 广告

评论区