当前位置:文档之家› CCNA基础命令

CCNA基础命令

show interface 显示路由器中所有接口相关的信息
show ip interface brief 显示路由器上当前激活或未激活的网络接口
show version 可以被用来检测和排除路由器基本硬件和软件问题
enable 特权模式
级别0的命令 disable enable exit help logout
configure terminal 全局配置模式
interface type number 进入接口的命令格式
interface type slot#/port-adapter#/port 进入接口的命令格式(复杂)
show running-config 查看路由器上的接口数量和类型
terminal editing 打开高级编辑功能
terminal no editing 关闭高级编辑功能
terminal history size ?<0-256> size of history buffer 历史命令缓存记录,最大可以是256条
terminal history size 20 这里把命令缓存记录数设置成20条
show history 查看缓存的历史命令
show no history 关闭历史缓存
terminal history 打开历史命令缓存功能
terminal no history size 把缓存数恢复成默认的10条
hostname 路由器命名
clock set 设置路由器的系统日历
hh:mm:ss day month year
hh:mm:ss month day year 两种格式之一
route#clock set 8:40:00 12 june 2008 UTC时间,比北京时间晚8小时
router(config)#clock timezone GMT +8 改变时区clock timezone
Continue with configuration dialog? 你要进行路由器配置吗
description(描述) this port(接口) is link(连接) to internet 端口描述
int s1/1 配置路由器广域网接口serial1/1
ip address(地址) 12.1.1.1 255.255.255.0 配置IP地址和子网掩码
no shutdown 打开接口 默认接口是关闭的(no shut)
clock rate 64000 在电缆的DCE端口使用clock rate(时钟频率)配置时钟
exit 返回全局
int fa 0/1 配置局域网接口fastethernet 0/1
ip add 13.1.1.1 255.255.255.0
ip add 31.1.1.1 255.255.255.0 secondary(第二个 副手)一个接口配置更多地址
no shut
no ip address 【ip】【子网掩码】 取消接口多个IP地址
no ip address 删除该接口下的所有ip地址
line console 0 配置console端口密码
password cisco
login
enable password 123456 配置特权密码(用户到特权的密码)
enable secrt a123456 当secret和password同时使用password失效
line vty 0 4 虚拟终端用户0 4 5个并发登录
password cisco 设置密码cisco
login 账号(no login 不需要密码就可以登录)
service password-encryption 对所有的密码加密 (no ***取消加密)

配置路由器远程登录
r1配置
en
configure t
hostname r1
int s0/0/0
ipaddress 12.1.1.1 255.255.255.0
no shutdown
r2配置
en
conf t
host r2
int s0/0/0
ip add 12.1.1.2 255.255.255.0
no shutd
line vty 0 4
password cisco
login
line console 0
logging synchronous (同步日志)


show sessin 查看路由器r1上打开的会话

access-list(访问列表) 1 permit(允许) 12.1.1.1 限制VTY登录
line vty 0 4
access-class 1 in

no ip domain-lookup 关闭

域名查找(关闭域名解析)

ip host abc 12.1.1.2 ip host命令主机名列表
telnet abc 远程12.1.1.2
show host 查看路由器上配置的主机名
ip name-sever dns 服务器的ip地址 在路由器上配置DNS服务器的命令
ip name-sever 12.1.1.2 配置使用DNS 再输入域名https://www.doczj.com/doc/294023384.html,

简单的网络配置管理和排错
a1配置
en
conf t
host a1
int fa 0/0
ip add 192.168.1.1 255.255.255.0
no shut
int s0/0/1
ip add 12.1.1.1 255.255.255.0
no shut


a2配置
en
conf t
host a2
int s0/0/0
ip add 12.1.1.2 255.255.255.0
no shut
int s0/0/1
ip add 23.1.1.2 255.255.255.0
no shut


a3配置
en
conf t
host a3
int s0/0/0
ip add 23.1.1.3 255.255.255.0
no shut
exit
int loopback ? 查看路由器上支持的换回接口数量
int loopback 0 配置路由器上的环回接口
ip add 3.3.3.3 255.255.255.0


interface lo 0 关闭回环
shutdown



debug ip icmp 命令--调试、IP、ICMP
ICMP packet debugging is on ICMP 上的调试

undebug all 关闭所有调试
All possible debugging has been turned off 所有可能的调试已经关闭

show ip route 查看 路由表

C 表示直连路由
S 表示静态路由
R 表示RIP(路由信息协议,动态路由协议的一种)
D 表示EIGRP(增强内部网关路由协议,动态路由协议的一种)
O 表示OSPF(开放式最短路径优先,也是动态路由协议)
* 表示默认路由

添加一条静态协议
en
config t
ip route 192.168.1.0 255.255.255.0 12.1.1.1


interface lo 0 关闭回环
shutdown


a1
ip route 0.0.0.0 0.0.0.0 12.1.1.2

a2
ip route 192.168.1.0 255.255.255.0 12.1.1.1
ip route 3.3.3.0 255.255.255.0 23.1.1.3

a3

ip route 0.0.0.0 0.0.0.0 23.1.1.2



!!!!! 收到显示
.....环路超时
UUUU 数据包不可达



高级ping命令

a1#ping
Protocol [ip]:
Target IP address: 3.3.3.3 ping的地址
Repeat count [5]: 20 ping包个数
Datagram size [100]: ping包默认大小100字节
Timeout in seconds [2]: 默认时间两秒,2秒无应答算超时
Extended commands [n]: y 是否要进一步扩展命令
Source address or interface: 192.168.1.1 不填的话将使用离目标最近的端口,
Type of service [0]:
Set DF bit in IP header? [no]:
Validate reply data? [no]:
Data pattern [0xABCD]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Sweep range of sizes [n]:
Type escape sequence to abort.
Sending 20, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
Packet sent with a source address of 192.168.1.1
!!!!!!!!!!!!!!!!!!!!
Success rate is 100 percent (20/20), round-trip min/avg/max = 2/3/8 ms



traceroute 命令
traceroute -d 不执行反向解析(更快)
路由器上可以用简写 tr 但是不是写成tracert
电脑上只能用tracert


常用的排错命令
show interface 查看的路由器的接口状态
具体接口的话 show interfac

e fa 0/0
line protocol is up 协议是正常的
show ip interface 查看接口与IP相关的信息
show ip interface brief 显示网络接口简介
show arp 查看路由器的ARP表 相当于计算机上的arp -a
clear arp 清除arp缓存 相当计算机是的 arp -d
show controllers 查看接口的硬件信息,接口连接线缆的类型(显示控制器)



文件管理

show running-config 查看运行配置文件
more 回车一行 空格一页 任意键退出
copy running-config startup-config 保存配置文件
简写为 copy run start 用运行配置文件覆盖启动配置文件
或者
write 写 一般简写成wr 用运行配置文件覆盖启动配置文件

拷贝运行文件到TFTP服务器
copy startup-config tftp

恢复配置文件 copy startup-config running-config 这里是合并不是覆盖
或者从TFTP恢复配置
copy tftp running-config
输入IP
名称


启动配置文件管理
备份和恢复
#copy startup-config tftp
#copy tftp startup-config
删除启动配置文件
erase startup-config
要取消对路由器的配置 一般是前面加no

4.5 cdp协议
工作在OSI7层模型的第二层 数据链路层,思科公司私有协议,不能用于非思科设备

show cdp 查看CDP全局信息
fig#cdp timer 10 更改cdp发送时间间隔是10秒
cdp holdtime 40 cdp保持时间是40秒
no cdp run 关闭CDP协议 开启是cdp run
do show cdp 加do在其他模式下调用特权命令 packet tracer 不支持

cdp is not enabled
show cdp interface 查看那些端口运行了CDP
no cdp enable 在接口模式下关闭接口的cdp协议
在接口模式下打开cdp cdp enable
show cdp neighbors 收集邻居信息(显示邻居)
Device ID Local Intrfce Holdtme Capability Platform Port ID
a1 Ser 0/0/1 120 R C1841 Ser 0/0/0
Device ID 邻居hostname
Local Intrfce 当前设备的本地接口
Holdtme 保持时间
Capability 连接的设备 R 表示路由器 S 表示交换机 RS 路由交换机
Platform 设备的具体型号
Port ID 远端设备的连接端口


show cdp neighbors detail 显示连接到此设备的邻居设备的详细信息
Device ID: a1 名称
Entry address(es): 地址
IP address : 12.1.1.1
Platform: cisco C1841, Capabilities: Router
Interface: Serial0/0/1, Port ID (outgoing port): Serial0/0/0
Holdtime: 138 保持时间

Version : 版本信息
Cisco IOS Software, 1841 Software (C1841-ADVIPSERVICESK9-M), Version 12.4(15)T1, RELEASE SOFTWARE (fc2)
Technical Support: https://www.doczj.com/doc/294023384.html,/techsupport
Copyright (c) 1986-2007 by Cisco Systems, Inc.
Compiled Wed 18-Jul-07 04:52 by pt_team

advertisement version: 2 vtp版本2
Duplex: full 双工显示半双工

show cdp entry * 等同于show cdp neighbors detail
show cdp entry 后面可以直接加邻居设备名
show cdp traffic 显示

发送和接收cdp数据包的数量及cdp出错信息
cler cdp conunters 清除cdp收发数据包计数器
debug cdp events 显示cdp事件信息


路由器选择协议
route print 显示当前主机的路由 真实计算机
route add 添加路由
route delete 删除路由 route /? 查看在线帮助

routing protocol 路由协议 RIP、EIGRP、OSPF
routed protocol 被路由协议 IP、IPX、AppleTalk










顺便说下推荐的网络检测,排错的顺序与方法:
1.ping 127.0.0.1 先检查TCP/IP协议栈是否正常
2.ping 本地ip 检查你网卡是否工作正常
3.ping 网关地址 检查和网关连接性
4.ping 远程网站 检查远程连接

相关主题
文本预览
相关文档 最新文档