当前位置: 首页 > CCNA > CCNA命令大全汇总

CCNA命令大全汇总

客服
蔡老师思科答疑老师
思博金牌讲师
客服
客服
客服
更新时间:2018年07月05日   作者:spoto | ccna命令  网络工程师命令  R1命令  

登录网络设备,USB-COM-COM-RJ45,超级终端  /SecureCRT

Would you like to enter the initial configuration dialog? [yes/no]:// 回答 no ,如果回答了 yes ,会出现大量对话,Ctrl+C中断对话

% Please answer 'yes' or 'no'.

Router>// 用户模式,只能简单的show及 ping/tracer

Router>enable// 从用户模式进入特权模式

Router#// 特权模式,能够进行所有的show及 ping/tracerRouter#configure terminal// 从特权模式进入全局配置模式Router(config)#// 全局配置模式,可以进行相关配置Router(config)#hostname R1// 给设备命名 

R1#show version// 查看设备软硬件版本信息,开机时间,内存和Flash 大小,模块等

R1#show ip interface brief// 查看接口信息

R1#show running-config// 查看运行在内存中的当前配置

R1#show startup-config// 查看开机配置,保存在NVRAM

R1#copy running-config startup-config// 将当前运行配置保存到开机配置中

R1#show tech-support// 查看设备所有软硬件的详细信息

R1(config)#enable password xxx// 配置  enable密码,该密码show run可见 

R1(config)#enable secret xxx// 配置  enable密码,该密码show run不可见,两个同时配置时,secret密码生效

R1(config)#line vty 0 4// 进入telnet配置模式

R1(config-line)#login//telnet登陆需要密码验证

R1(config-line)#password xxx  // 配置 telnet 密码

R1(config-line)#exit 

R1(config)#line vty 0 4

R1(config-line)#no login//telnet登陆不需要验证

R1(config-line)#exit

R1(config)#line vty 0 4

R1(config-line)#login local//telnet登陆需要在本地数据库查找用户名密码进行验证

R1(config-line)#exit

R1(config)#username spoto password xxx// 创建本地用户名密码

R1(config)#banner ^!!!!R1!!!!!^// 配置设备登陆提示符,头尾符号需要一致,中间为提示符内容 

R1(config)#line vty 0 4

R1(config-line)#privilege level 15// 配置 telnet用户特权等级为15 ,即登陆后直接进入

enable模式

R1(config-line)#exit

R1(config)#interface fastEthernet x/x// 进入接口配置模式

R1(config-if)#ip address x.x.x.x x.x.x.x// 配置IP及掩码

R1(config-if)#no shutdown// 打开接口,路由器接口默认处于管理性关闭状态

R1(config-if)#exit// 退出接口配置模式,返回全局配置模式R1(config)#no ip routing// 关闭路由功能,将路由器模拟成PCR1(config)#ip default-gateway x.x.x.x// 配置网关地址

R1#show ip route  // 查看关闭路由功能后的网关配置

 

R1#show cdp neighbors  // 查看思科互连设备信息

R1(config)#interface loopback 0// 创建环回接口0 ,用于模拟网段和测试

R1(config-if)#ipaddressx.x.x.xx.x.x.x // 配置环回接口IP 及掩码,环回接口不需要no shutdown 

R1(config-if)#exit

R1(config)#ip route x.x.x.x x.x.x.x x.x.x.x// 配置使用下一跳地址的静态路由 

R1(config)#ip route x.x.x.x x.x.x.x fastEthernet x/x// 配置使用本地出接口的静态路由 

R1(config)#ip route 0.0.0.0 0.0.0.0 x.x.x.x// 配置使用下一跳地址的默认路由 

R1(config)#ip route 0.0.0.0 0.0.0.0 fastEthernet x/x// 配置使用本地出接口的默认路由 

R1#show ip route// 查看路由表

R1#ping x.x.x.x // 使用出接口作为源IP 的普通ping

R1#ping x.x.x.x source x.x.x.x// 使用指定源地址的扩展ping

R1#debug ip icmp// 打开 ping的调试过程显示

R1#undebug ip icmp// 关闭 ping的调试过程显示

R1#traceroute x.x.x.x// 路径跟踪,查看到达目的地所经过的IPR1(config)#router rip// 运行RIP协议,进入RIP协议配置模式R1(config-router)#version 2// 配置 RIP为版本 2 

R1(config-router)#no auto-summary// 关闭自动汇总功能

R1(config-router)#networkx.x.x.x  // 将相关网段发布到RIP 进程中,所有相关子网都会 被发布,命令配置不支持带掩码

R1(config-router)#exit // 退出 RIP 协议配置模式

R1(config)#router   eigrp  x // 运行 EIGRP ,配置  EIGRP  AS 号码,相邻设备的AS 号码要求一致

 

R1(config-router)#no auto-summary// 关闭自动汇总功能

R1(config-router)#networkx.x.x.x  // 将相关网段发布到EIGRP 进程中,所有相关子网都会被发布

R1(config-router)#network x.x.x.x x.x.x.x // 将相关网段精确发布到EIGRP 进程中,命令 配置支持带反掩码 

R1(config-router)#exit       // 退出 EIGRP 协议配置模式 R1#show ip eigrp neighbors        // 查看 EIGRP 邻居表 R1#show ip eigrp topology       // 查看 EIGRP 拓扑表

R1(config)#router ospf x// 运行 OSPF ,配置OSPF 本地进程号,该号码仅有本地意义 

R1(config-router)#network x.x.x.x x.x.x.x area x// 相关网段精确发布到OSPF区域中,命令配置要求带反掩码,相邻设备区域号要相同

R1(config-router)#auto-cost reference-bandwidth x// 修改参考带宽,单位是兆

R1(config-router)#exit // 退出 OSPF 协议配置模式 

R1#show ip ospf neighbor // 查看OSPF邻居表 R1#show ip ospf database// 查看OSPF拓扑表 

R1#showipospfinterface// 查看 OSPF 接口状态信息,包括RID 、网络类型、hello时间等 

在 C3640上加载NM-16ESW模块来模拟交换机。如果是模拟2 层交换机,需要关闭路由功能。

Switch(vlan)#vlan x  // 创建VLAN ,删除时前面加no求一致

 

Switch#vlan database // 进入VLAN数据库模式

Switch(vlan)#vlan x  // 创建 VLAN ,删除时前面加no

 

Switch(vlan)#exit

Switch#show vlan-switch // 查看VLAN表及所属端口,真实设备或IOU 模拟器上的命令为 show vlan

Switch#show vtp status // 查看 VTP 信息,包括域名、版本、模式等

Switch(config)#int fastEthernet x/x

Switch(config-if)#switchport mode access// 配置端口模式为access

Switch(config-if)#switchport access vlan 10// 将该端口划入VLAN10,默认所有端口属于VLAN1 

Switch(config-if)#exit

Switch(config)#int fastEthernet x/x// 进入单臂路由主接口

Switch(config-if)#switchporttrunkencapsulationdot1q//指定trunk封装使用802.1Q ,当交换机支持802.1Q和 ISL时使用

Switch(config-if)#switchport mode trunk// 配置端口模式为trunk

Switch(config-if)#exit

Switch#show interfaces trunk// 查看交换机trunk接口信息及状态 

Switch(config)#interface vlan x// 进入管理IP所在的接口Switch(config-if)#ip address x.x.x.x x.x.x.x// 配置交换机的管理IP 

Switch(config-if)#exit

Switch(config)#ip default-gateway x.x.x.x// 配置交换机的网关地址,实现跨网段远程管理 

R1(config)#interface fastEthernet x/x

R1(config-if)#no shutdown  // 单臂路由配置,只需要主接口开启,子接口会自动继承开启

R1(config-if)#exit

R1(config)#interface fastEthernet x/x.x// 进入子接口配置模式

R1(config-subif)#encapsulation dot1Q x// 配置封装为802.1Q  ,并指定该子接口所对应的VLAN

R1(config-subif)#ip address x.x.x.x x.x.x.x// 配置该VLAN的网关地址

R1(config-subif)#exit

R1(config)#access-list x permit x.x.x.x// 允许来自某台主机的流量 

R1(config)#access-list x permit x.x.x.x x.x.x.x// 允许来自某个网段的流量 

R1(config)#access-list x deny any// 标准 ACL 的默认操作是拒绝所有流量 

R1(config)#interface fastEthernet x/x

R1(config-if)#ip access-group x in// 将 CAL 应用在接口的入方向

R1(config-if)#ip access-group x out// 将ACL应用在接口的出方向

R1(config-if)#exit

R1(config)#line vty 0 4

R1(config-line)#access-class1in  //telnet远程控制,有在ACL 中被允许的主机能远程telnet到本机。

R1(config-line)#exit

R1(config)#access-list 100 permit ip x.x.x.x x.x.x.x x.x.x.x x.x.x.x// 允许某个网段到某个网段的流量通过 

R1(config)#access-list 100 permit ip host x.x.x.x host x.x.x.x// 允许某台主机到某台主机的流量通过

R1(config)#access-list 100 permit ip any any // 允许任何IP 流量通过

R1(config)#access-list 100 permit tcp any any eq x // 允许某种TCP流量通过

R1(config)#access-list 100 permit udp any any eq x// 允许某种UDP流量通过

R1(config)#access-list 100 permit icmp any any// 允许 ping包通过 

R1(config)#access-list 100 deny ip any any// 扩展 ACL 的默认操作是拒绝所有流量 

R1#show access-lists// 查看ACL内容及匹配情况 

R1(config)#interface fastEthernet x/x

R1(config-if)#ip nat inside// 指定接口为NAT的 inside端

R1(config)#interface fastEthernet x/x

R1(config-if)#ip nat outside// 指定接口为NAT的outside端

R1(config)#ip nat inside source list 1 interface fastEthernet x/x overload// 配置基于出接口的PAT 

R1(config)#access-list 1 permit any// 允许任何IP作为NAT的源地址

R1(config)#ip nat inside source static x.x.x.x x.x.x.x// 配置静态NAT

R1(config)#ip nat pool spoto x.x.x.x x.x.x.x netmask 255.255.255.0// 配置NAT的地址池

R1(config)#ip nat inside source list 1 pool spoto overload// 配置基于地址池的PAT 

R1(config)#ip nat inside source static tcp x.x.x.x x interface FastEthernetx/x x// 配置静态端口映射

R1#show ip nat translations// 查看 NAT转换表

R1#clear ip nat translation *// 清除 NAT转换表,静态条目不会被删除

R1-S/C(config)#int serial x/x

R1-S/C(config-if)#clock rate 64000

R1-S/C(config-if)#encapsulation ppp  / 将接口封装从默认的HDLC改为 PPP 封装PAP 认证配置,认证服务器端: 

R1-S(config)#username xxx password xxx   // 在认证服务器端配置本地用户名密码 

R1-S(config-if)#ppp authentication pap   // 在认证服务器端开启pap认证要求 PAP 认证配置,认证客户端: 

R1-C(config-if)#ppppapsent-username xxxpasswordxxx  // 在认证客户端配置pap发送的用户名和密码CHAP  认证配置,认证服务器端:

R1-S(config)#username xxx password xxx// 在认证服务器端配置本地用户名密码 

R1-S(config-if)#ppp authentication chap// 在认证服务器端开启chap认证要求CHAP认证配置,认证客户端: 

R1-C(config-if)#ppp chap hostname xxx // 在认证客户端配置 chap发送的用户名 

R1-C(config-if)#ppp chap password xxx// 在认证客户端配置chap发送的密码 

FRSW(config)#frame-relay switching// 将路由器模拟成帧中继交换机 

FRSW(config)#int serial x/x

FRSW(config-if)#clock rate 64000 

FRSW(config-if)#encapsulationframe-relay// 将接口封装从默认的HDLC改为帧中继 封装 

FRSW(config-if)#frame-relay intf-type dce// 指定帧中继交换机接口类型为DCE 

FRSW(config-if)#frame-relay route xxx interface serial x/x xxx// 配置帧中继交换路径 

FRSW(config-if)#exit

FRR(config)#int serial x/x

FRR(config-if)#encapsulation   

frame-relay// 配置帧中继路由器接口封装从默认HDLC改为 FR

FRR(config-if)#ip address x.x.x.x x.x.x.x

FRR(config-if)#frame-relay map ip x.x.x.x x broadcast// 静态配置IP 到 DLCI 的映射关 系,指定对端IP 及本端使用的DLCI 值 

FRR(config-if)#exit

FRR#show frame-relay map// 查看帧中继映射表

FRR(config)#int serial x/x

FRR(config-if)#ipospfnetworkpoint-to-multipoint// 帧中继下OSPF默认模式是NBMA  ,无法自动建立邻居。手动修改网络类型为PTMP 或 PTP FRR(config-if)#exit 

CCNA关键知识: 网络模型、  IP&VLSM 静态路由 & 默认路由 

动态路由RIPv2 、 EIGRP 、 OSPF、VLAN 、Access 、Trunk、VTP 、STP 、单臂路由、2 层交换机远程管理、ACL 、NAT WAN、PPP 、 IPv6 、 WLAN

相关课程内容推荐 

 

思科认证备考须知:CCNA 备考指南

思博全新思科课程399活动价限额限时优惠:新版CCNA 课程

思博CCNA课程安排表: CCNA课表

网工必备证书:什么是思科认证CCNA

学习方法建议【干货】:ccna 新手怎么学?

 

热门推荐
最新推荐
bg
客服 扫码咨询考证课程


即刻预约

免费试听-咨询课程-获取免费资料

思博网络SPOTO新活动