交换机支持的命令:
交换机基本状态switch 路由器是rommon>
hostname> 用户模式 hostname# 特权模式
hostname(config)# 全局配置模式
hostname(config-if)# 接口状态 交换机口令设置:
switch>enable 进入特权模式
switch#config terminal 进入全局配置模式
switch(config)#hostname 设置交换机的主机名
switch(config)#enable secret xxx 设置特权加密口令
switch(config)#enable password xxa 设置特权非密口令
switch(config)#line console 0 进入控制台口
switch(config-line)#line vty 0 4 进入虚拟终端
switch(config-line)#login 允许登录
switch(config-line)#password xx 设置登录口令xx
switch#exit 返回命令 交换机VLAN设置:
switch#vlan database 进入VLAN设置
switch(vlan)#vlan 2 建VLAN 2
switch(vlan)#no vlan 2 删vlan 2
switch(config)#int f0/1 进入端口1
switch(config-if)#switchport access vlan 2 当前端口加入vlan 2
switch(config-if)#switchport mode trunk 设置为干线
switch(config-if)#switchport trunk allowed vlan 1,2 设置允许的vlan
switch(config-if)#switchport trunk encap dot1q 设置vlan 中继
switch(config)#vtp domain 设置vtp域名
switch(config)#vtp password 设置vtp密码
switch(config)#vtp mode server 设置vtp模式
switch(config)#vtp mode client 设置vtp模式
交换机设置IP地址:
switch(config)#interface vlan 1 进入vlan 1
switch(config-if)#ip address 设置IP地址
switch(config)#ip default-gateway 设置默认网关
switch#dir flash: 查看闪存 交换机显示命令:
switch#write 保存配置信息
switch#show vtp 查看vtp配置信息
switch#show run 查看当前配置信息
switch#show vlan 查看vlan配置信息
switch#show interface 查看端口信息
switch#show int f0/0 查看指定端口信息
路由器支持的命令:
路由器显示命令:
router#show run 显示配置信息 \\
router#show interface 显示接口信息
router#show ip route 显示路由信息
router#show cdp nei 显示邻居信息
router#reload重新起动
路由器口令设置:
router>enable 进入特权模式
router#config terminal 进入全局配置模式
router(config)#hostname 设置交换机的主机名
router(config)#enable secret xxx 设置特权加密口令
router(config)#enable password xxb 设置特权非密口令
router(config)#line console 0 进入控制台口
router(config-line)#line vty 0 4 进入虚拟终端
router(config-line)#login 要求口令验证
router(config-line)#password xx 设置登录口令xx
router(config)#(Ctrl+z) 返回特权模式
router#exit 返回命令
路由器配置:
router(config)#int s0/0 进入Serail接口
router(config-if)#no shutdown 激活当前接口
router(config-if)#clock rate 000 设置同步时钟
router(config-if)#ip address 设置IP地址
router(config-if)#ip address second 设置第二个IP
router(config-if)#int f0/0.1 进入子接口
router(config-subif.1)#ip address 设置子接口IP
router(config-subif.1)#encapsulation dot1q 绑定vlan中继协议
router(config)#config-register 0x2142 跳过配置文件
router(config)#config-register 0x2102 正常使用配置文件
router#reload 重新引导 路由器文件操作:
router#copy running-config startup-config 保存配置
router#copy running-config tftp 保存配置到tftp
router#copy startup-config tftp 开机配置存到tftp
router#copy tftp flash: 下传文件到flash
router#copy tftp startup-config下载配置文件
ROM状态:
Ctrl+Break 进入ROM监控状态
rommon>confreg 0x2142 跳过配置文件
rommon>confreg 0x2102 恢复配置文件
rommon>reset 重新引导
rommon>copy xmodem: flash: 从console传输文件
rommon>IP_ADDRESS=10.65.1.2 设置路由器IP
rommon>IP_SUBNET_MASK=255.255.0.0 设置路由器掩码
rommon>TFTP_SERVER=10.65.1.1 指定TFTP服务器IP
rommon>TFTP_FILE=c2600.bin 指定下载的文件
rommon>tftpdnld 从tftp下载
rommon>dir flash: 查看闪存内容
rommon>boot 引导IOS
静态路由:
ip route 命令格式
router(config)#ip route 2.0.0.0 255.0.0.0 1.1.1.2 静态路由举例
router(config)#ip route 0.0.0.0 0.0.0.0 1.1.1.2 默认路由举例 动态路由:
router(config)#ip routing 启动路由转发
router(config)#router rip 启动RIP路由协议。
router(config-router)#network 设置发布路由
router(config-router)#negihbor 点对点帧中继用。
帧中继命令:
router(config)#frame-relay switching 使能帧中继交换
router(config-s0)#encapsulation frame-relay 使能帧中继
router(config-s0)#fram-relay lmi-type cisco 设置管理类型
router(config-s0)#frame-relay intf-type DCE 设置为DCE
router(config-s0)#frame-relay dlci 16
router(config-s0)#frame-relay local-dlci 20 设置虚电路号
router(config-s0)#frame-relay interface-dlci 16
router(config)#log-adjacency-changes 记录邻接变化
router(config)#int s0/0.1 point-to-point 设置子接口点对点
router#show frame pvc 显示永久虚电路
router#show frame map 显示映射
基本访问控制列表:
router(config)#access-list permit|deny
router(config)#interface
default:deny any
router(config-if)#ip access-group in|out
default:out
例1:
router(config)#access-list 4 permit 10.8.1.1
router(config)#access-list 4 deny 10.8.1.0 0.0.0.255
router(config)#access-list 4 permit 10.8.0.0 0.0.255.255
router(config)#access-list 4 deny 10.0.0.0 0.255.255.255
router(config)#access-list 4 permit any
router(config)#int f0/0
router(config-if)#ip access-group 4 in
扩展访问控制列表:
access-list permit|deny icmp access-list permit|deny tcp 例3: router(config)#access-list 101 deny icmp any 10..0.2 0.0.0.0 echo router(config)#access-list 101 permit ip any any router(config)#int s0/0 router(config-if)#ip access-group 101 in 例3: router(config)#access-list 102 deny tcp any 10.65.0.2 0.0.0.0 eq 80 router(config)#access-list 102 permit ip any any router(config)#interface s0/1 router(config-if)#ip access-group 102 out 删除访问控制例表: router(config)#no access-list 102 router(config-if)#no ip access-group 101 in 路由器的nat配置 Router(config-if)#ip nat inside 当前接口指定为内部接口 Router(config-if)#ip nat outside 当前接口指定为外部接口 Router(config)#ip nat inside source static [p] <私有IP><公网IP> [port] Router(config)#ip nat inside source static 10.65.1.2 60.1.1.1 Router(config)#ip nat inside source static tcp 10.65.1.3 80 60.1.1.1 80 Router(config)#ip nat pool p1 60.1.1.1 60.1.1.20 255.255.255.0 Router(config)#ip nat inside source list 1 pool p1 Router(config)#ip nat inside destination list 2 pool p2 Router(config)#ip nat inside source list 2 interface s0/0 overload Router(config)#ip nat pool p2 10.65.1.2 10.65.1.4 255.255.255.0 type rotary Router#show ip nat translation rotary 参数是轮流的意思,地址池中的IP轮流与NAT分配的地址匹配。 overload参数用于PAT 将内部IP映射到一个公网IP不同的端口上。 外部网关协议配置: routerA(config)#router bgp 100 routerA(config-router)#network 19.0.0.0 routerA(config-router)#neighbor 8.1.1.2 remote-as 200 配置PPP验证: RouterA(config)#username password RouterA(config)#int s0 RouterA(config-if)#ppp authentication {chap|pap} 3. PIX防火墙命令 Pix525(config)#nameif ethernet0 outside security0 命名接口和级别 Pix525(config)#interface ethernet0 auto 设置接口方式 Pix525(config)#interface ethernet1 100full 设置接口方式 Pix525(config)#interface ethernet1 100full shutdown Pix525(config)#ip address inside 192.168.0.1 255.255.255.0 Pix525(config)#ip address outside 133.0.0.1 255.255.255.252 Pix525(config)#global (if_name) natid ip-ip 定义公网IP区间 Pix525(config)#global (outside) 1 7.0.0.1-7.0.0.15 例句 Pix525(config)#global (outside) 1 133.0.0.1 例句 Pix525(config)#no global (outside) 1 133.0.0.1 \\ 去掉设置 Pix525(config)#nat (if_name) nat_id local_ip [netmark] Pix525(config)#nat (inside) 1 0 0 内网所有主机(0代表0.0.0.0)可以访问global 1指定的。 Pix525(config)#nat (inside) 1 172.16.5.0 255.255.0.0 内网172.16.5.0/16网段的主机可以访问global 1指定的。 Pix525(config)#route if_name 0 0 gateway_ip [metric] 命令格式 Pix525(config)#route outside 0 0 133.0.0.1 1 例句 Pix525(config)#route inside 10.1.0.0 255.255.0.0 10.8.0.1 1 例句 Pix525(config)#static (inside, outside) 133.0.0.1 192.168.0.8 表示内部ip地址192.168.0.8,访问外部时被翻译成133.0.0.1全局地址。 Pix525(config)#static (dmz, outside) 133.0.0.1 172.16.0.8 中间区域ip地址172.16.0.8,访问外部时被翻译成133.0.0.1全局地址。 Cisco路由器的基础配置 1、路由器模式详解: Router>用户模式,通常用来查看统计信息,但不能修改路由器的设置。 Router#特权模式,可以查看并修改路由器的配置,通常在这里运行show命令。 Router(config)# 全局模式,在这里修改当前运行配置中的内容。 Router(config-if)#接口模式,用来配置路由器的物理接口和环回接口。 Router(config-line)#控制台接口模式,通常用来配置用户模式口令,如Telnet的登录密码。 Router(config-subif)#子接口模式,用来配置在路由器中创建的逻辑接口 Router(config-router)#路由协议接口模式,在这里配置路由协议,如RIP、OSPF、IGRP等。 2、常用的show命令: 查看路由信息 Router#show ip route 查看路由器版本 Router#show version 查看路由器flash Router#show flash: 查看历史命令记录 Router#show history 查看路由器ARP表 Router#show arp 查看路由器的时间设置 Router#show clock 查看接口简要信息 Router#show ip interface brief 查看接口物理相关信息 Router#show interfaces s0/0 查看接口协议相关信息 Router#show ip interface s0/0 查看路由器运行配置文件 Router#show running-config 查看当前所有连接到路由器的用户 Router#show users 查看会话记录,经常在终端上使用 Router#show session 查看特定接口的硬件信息 Router#show controllers s0/0 查看全局和接口的第三层协议的特定状态 Router#show protocols 查看下次路由器重新加载时将要使用的配置 Router#show startup-config CDP思科发现协议,查看直连的相邻设备及其详细信息 Router#show cdp neighbors 3、登录路由器必要的配置: Router>enable //进入特权模式 Router#configure terminal //进入全局模式 Router(config)#hostname R1 //配置路由器的主机名 R1(config)#no ip domain-lookup//关闭动态的域名解析,作用是当我们输入错误命令的时候,路由器会认为这条命令没有错误,它只是一个域名的形式,路由器会进行解析,从而浪费宝贵的时间。 R1(config)#line console 0 //进入控制台 R1(config-line)#exec-timeout 0 0 //关闭控制台的会话超时,也可用命令no exec-timeout,当长时间不去操作路由器的时候,路由器会自动的终止与我们的对话连接,跳转到非连接状态,这时候,需要输入enable 密码重新登录,从某种意义上来讲是对安全性得到了保证,但对我们的操作却是十分的不方便。 R1(config-line)#logging synchronous //关闭日志同步,抑制控制台的提示信息,使得路由器发送的控制台屏幕的消息不会附加到命令行中。 路由器的口令设置 Router>enable//进入特权模式 Router#configure terminal //进入全局模式 Router(config)#enable password cisco1 //配置进入特权模式的密码(明文密码),使用命令show running-config可以查看到设置的密码。 Router(config)#enable secret cisco2 //配置进入特权模式的密码(密文密码),使用命令show running-config查看时,设置的密码是以密文显示,权限更高。 Router(config)#line console 0 //进入控制台 Router(config-line)#password cisco //设置登录到路由器的密码,在进入用户模式时验证。 Router(config-line)#login //启用登录 Router(config-line)#line vty 0 4 //设置telnet访问路由器的5条线路,也可在全局模式下进入 Router(config)#line vty 0 4。 Router(config-line)#password cisco //设置telnet到路由器的密码,如果不设置此密码,服务将无法启动。 Router(config-line)#login Router(config-line)#line aux 0 Router(config-line)#password 123 //设置辅助接口的密码 Router(config-line)#login Router(config-line)#exit //退出 Router(config)#service password-encryption//此命令用来加密口令,对路由器配置的所有口令都进行加密,如设置的enable password查看时是以明文显示,使用此命令后,通过命令show running-config查看时,是以密文显示。 路由器或交换机上常用的测试和诊断命令及其功能 1、通用测试、诊断命令 1) ping x.x.x.x -------- 标准ping命令,用于测试设备间的物理连通性 2) ping -------- 扩展ping命令,用于测试设备间的物理连通性。扩展ping命令还支持灵活定义ping参数,如ping数据包的大小、发送包的个数、等待响应数据包的超时时间等 3) traceroute x.x.x.x -------- 用于跟踪、显示路由信息 4) show running-config -------- 用于显示路由器、交换机运行配置文件的内容 5) show startup-config -------- 用于显示路由器、交换机启动配置文件的内容 6) show sessions -------- 用于显示从当前设备发出的所有呼出Telnet会话 7) disconnect -------- 用于断开与远程目标主机的Telnet会话 8) show users -------- 用于查看呼入Telnet会话情况 9) clear line -------- 用于断开远程主机的呼入Telnet连接 10) shutdown -------- 用于临时将某个接口关闭 11) no shutdown -------- 用于手动启动(激活)处于管理性关闭的接口 12) show arp -------- 用于显示ARP缓存(ARP表)的内容 13) show ip arp -------- 用于显示IP ARP缓存(ARP表)的内容 14) show ip interface -------- 用于显示IP接口的状态及配置信息 15) show version -------- 用于显示路由器硬件配置、软件版本等信息 16) show etherchannel summary -------- 用于显示端口捆绑的简要信息 17) Ctrl+Shift+6+x -------- 也被称为退出序列,用于终止正在执行的某条命令或操作,也用于从呼出Telnet会话中暂时切换到本地连接 18) dir flash -------- 用于显示闪存中的文件清单 19) dir nvram -------- 用于显示非易失性内存中的文件清单 20) show debugging -------- 用于显示正在进行的诊断过程清单 21) undebug all -------- 用于停止所有诊断过程 2、VLAN、VTP测试、诊断命令 1) show interface vlan vlan-num -------- 用于显示VLAN是否已激活、交换机MAC地址、接口参数等 2) show mac-address-table -------- 用于显示CAM,即桥接表的内容。该命令可列出学习到的主机MAC地址及其所属VLAN、所处端口、条目类型((静态static)、(动态 dynamic)等)以及满足列表条件的MAC地址数目 3) show vlan -------- 用于查看VLAN创建情况。该命令可以显示系统所有的VLAN信息,包括VLAN编号、VLAN名称、VLAN状态、VLAN成员等信息 4) show vtp status -------- 用于检查VTP配置情况 3、生成树测试、诊断命令 1) show spanning-tree -------- 用于显示生成树协议中交换机及其端口的情况 2) show spanning-tree blockedports -------- 用于显示处于阻塞状态的端口 3) show spanning-tree detail -------- 用于显示生成树详细信息 4) show spanning-tree interface -------- 用于显示生成树中某端口相关状态 5) show spanning-tree vlan -------- 当有多个VLAN时,Catalyst交换机会为每个VLAN运行一个生成树实例。此命令用于显示指定VLAN的生成树内容 6) show spanning-tree summary -------- 用于显示生成树总结,包括本交换机是哪些VLAN的根网桥、端口快速特性是否启用、处于生成树各个端口状态的端口数量等信息 4、路由和路由协议测试、诊断命令 1) show ip route -------- 用于显示当前路由表内容 2) show ip protocols -------- 用于显示动态路由协议的配置参数信息 5、ACL测试、诊断命令 1) show access-lists -------- 用于显示所有已定义的访问控制列表内容及命中情况 2) show ip access-lists -------- 用于显示所有已定义的ip访问控制列表内容及命中情况 6、NAT测试、诊断命令 1) show ip nat translation -------- 显示当前正在进行的NAT情况 2) show ip nat translation verbose -------- 用于显示当前正在进行的NAT更为详细的情况 3) show ip nat statistics -------- 用于显示NAT运行情况统计 4) debug ip nat -------- 用于打开对NAT的诊断 7、远程访问测试、诊断命令 1) show line -------- 用于查看当前系统所有的线路及其状态 2) show modemcap -------- 用于显示当前路由器可以自动配置的Modem列表 3) debug ppp negotiation -------- 用于打开对ppp参数协商的诊断 4) debug ppp authentication -------- 用于打开对ppp身份认证过程的诊断 8、CDP测试、诊断命令 1) show cdp -------- 用于显示CDP全局参数信息 2) show cdp neighbors -------- 用于显示CDP邻居设备的摘要信息 3) show cdp neighbors detail -------- 用于显示 CDP邻居设备的详细信息,包括:邻居设备名称、邻居设备接口IP地址、邻居设备软件版本信息、设备性能、设备平台、本地设备接口、邻居设备接口、CDP缓存条目保持时间、CDP广播版本、接口双工方式等 4) show cdp entry -------- 用于显示指定邻居设备的相关信息 5) show cdp interface -------- 用于显示本地设备各个接口的状态、接口封装格式、CDP包的周期发送时间以及CDP保持时间等 6) show cdp traffic -------- 用于显示和CDP相关的流量统计信息,包括接收和发送的CDP包数量,包括头部错误、校验错误、封装错误等在内的错误数量等 因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- azee.cn 版权所有 赣ICP备2024042794号-5
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务