计算机网络,思科CCNA命令大全,网工都会收藏的宝藏

小编:大闷头 更新时间:2022-04-30

以下是思科CCNA命令大全

点击收藏!!!


1、Would you like toenter the initial configuration dialog? [yes/no]:


//回答no,如果回答了yes,会出现大量对话,Ctrl+C中断对话


% Please answer 'yes' or 'no'.


2、Router>


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


3、Router>enable


//从用户模式进入特权模式


4、Router#


//特权模式,能够进行所有的show及ping/tracer


5、Router#configure terminal


//从特权模式进入全局配置模式


6、Router(config)#


//全局配置模式,可以进行相关配置


7、Router(config)#hostname R1


//给设备命名


8、R1#show version


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


9、R1#show ip interface brief


//查看接口信息


10、R1#show running-config


//查看运行在内存中的当前配置


11、R1#show startup-config


//查看开机配置,保存在NVRAM


12、R1#copy running-config startup-config


//将当前运行配置保存到开机配置中


13、R1#show tech-support


//查看设备所有软硬件的详细信息


14、R1(config)#enable password xxx


//配置enable密码,该密码show run可见,注意空格也是一位密码


15、R1(config)#enable secret xxx


//配置enable密码,该密码show run不可见,两个同时配置时,secret密码生效


16、R1(config)#line vty 0 4


//进入telnet配置模式


17、R1(config-line)#login


//telnet登陆需要密码验证


18、R1(config-line)#password xxx


//配置telnet密码,注意空格也是一位密码


19、R1(config-line)#exit


R1(config)#line vty 0 4


R1(config-line)#no login


//telnet登陆不需要验证


20、R1(config-line)#exit


R1(config)#line vty 0 4


R1(config-line)#login local


//telnet登陆需要在本地数据库查找用户名密码进行验证


21、R1(config-line)#exit


R1(config)#username spoto password xxx


//创建本地用户名密码,注意空格也是一位密码


22、R1(config)#banner ^!!!!R1!!!!!^


//配置设备登陆提示符,头尾符号需要一致,中间为提示符内容


23、R1(config)#line vty 0 4


R1(config-line)#privilege level 15


//配置telnet用户特权等级为15,即登陆后直接进入enable模式


24、R1(config-line)#exit


R1(config)#interface fastEthernet x/x


//进入接口配置模式


25、R1(config-if)#ip address x.x.x.x x.x.x.x


//配置IP及掩码


26、R1(config-if)#no shutdown


//打开接口,路由器接口默认处于管理性关闭状态


27、R1(config-if)#exit


//退出接口配置模式,返回全局配置模式


28、R1(config)#no ip routing


//关闭路由功能,将路由器模拟成PC


29、R1(config)#ip default-gateway x.x.x.x


//配置网关地址


30、R1#show ip route


//查看关闭路由功能后的网关配置


31、R1#show cdp neighbors


//查看思科互连设备信息,包括设备类型/名称/接口/IP等


32、R1(config)#interface loopback 0


//创建环回接口0,用于模拟网段和测试


33、R1(config-if)#ip address x.x.x.x x.x.x.x


//配置环回接口IP及掩码,环回接口不需要no shutdown


34、R1(config-if)#exit


R1(config)#ip route x.x.x.x x.x.x.x x.x.x.x


//配置使用下一跳地址的静态路由


35、R1(config)#ip route x.x.x.x x.x.x.x fastEthernet x/x


//配置使用本地出接口的静态路由


36、R1(config)#ip route 0.0.0.0 0.0.0.0 x.x.x.x


//配置使用下一跳地址的默认路由


37、R1(config)#ip route 0.0.0.0 0.0.0.0 fastEthernet x/x


//配置使用本地出接口的默认路由


38、R1#show ip route


//查看路由表


39、R1#ping x.x.x.x


//使用出接口作为源IP的普通ping


40、R1#ping x.x.x.x source x.x.x.x


//使用指定源地址的扩展ping


41、R1#debug ip icmp


//打开ping的调试过程显示


42、R1#undebug ip icmp


//关闭ping的调试过程显示


43、R1#traceroute x.x.x.x


//路径跟踪,查看到达目的地所经过的IP


44、R1(config)#router rip


//运行RIP协议,进入RIP协议配置模式


45、R1(config-router)#version 2


//配置RIP为版本2


46、R1(config-router)#no auto-summary


//关闭自动汇总功能


47、R1(config-router)#network x.x.x.x


//将相关网段发布到RIP进程中,所有相关子网都会被发布,命令配置不支持带掩码


48、R1(config-router)#exit


//退出RIP协议配置模式


49、R1(config)#router eigrp x


//运行EIGRP,配置EIGRP AS号码,相邻设备的AS号码要求一致


50、R1(config-router)#no auto-summary


//关闭自动汇总功能


51、R1(config-router)#network x.x.x.x


//将相关网段发布到EIGRP进程中,所有相关子网都会被发布


52、R1(config-router)#network x.x.x.x x.x.x.x


//将相关网段精确发布到EIGRP进程中,命令配置支持带反掩码


53、R1(config-router)#exit


//退出EIGRP协议配置模式


54、R1#show ip eigrp neighbors


//查看EIGRP邻居表


55、R1#show ip eigrp topology


//查看EIGRP拓扑表


56、R1(config)#router ospf x


//运行OSPF,配置OSPF本地进程号,该号码仅有本地意义


57、R1(config-router)#network x.x.x.x x.x.x.x area x


//相关网段精确发布到OSPF区域中,命令配置要求带反掩码,相邻设备区域号要相同


58、R1(config-router)#auto-cost reference-bandwidth x


//修改参考带宽,单位是兆


59、R1(config-router)#exit


//退出OSPF协议配置模式


60、R1#show ip ospf neighbor


//查看OSPF邻居表


61、R1#show ip ospf database


//查看OSPF拓扑表


62、R1#show ip ospf interface


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


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


63、Switch#vlan database


//进入VLAN数据库模式


64、Switch(vlan)#vlan x


//创建VLAN,删除时前面加no


65、Switch(vlan)#exit


Switch#show vlan-switch


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


66、Switch#show vtp status


//查看VTP信息,包括域名、版本、模式等


67、Switch(config)#int fastEthernet x/x


Switch(config-if)#switchport mode access


//配置端口模式为access


68、Switch(config-if)#switchport access vlan 10


//将该端口划入VLAN10,默认所有端口属于VLAN1


69、Switch(config-if)#exit


Switch(config)#int fastEthernet x/x


//进入单臂路由主接口


70、Switch(config-if)#switchport trunk encapsulation dot1q


//指定trunk封装使用802.1Q,当交换机支持802.1Q和ISL时使用


71、Switch(config-if)#switchport mode trunk


//配置端口模式为trunk


72、Switch(config-if)#exit


Switch#show interfaces trunk


//查看交换机trunk接口信息及状态


73、Switch(config)#interface vlan x


//进入管理IP所在的接口


74、Switch(config-if)#ip address x.x.x.x x.x.x.x


//配置交换机的管理IP


75、Switch(config-if)#exit


Switch(config)#ip default-gateway x.x.x.x


//配置交换机的网关地址,实现跨网段远程管理


76、R1(config)#interface fastEthernet x/x


R1(config-if)#no shutdown


//单臂路由配置,只需要主接口开启,子接口会自动继承开启


77、R1(config-if)#exit


R1(config)#interface fastEthernet x/x.x


//进入子接口配置模式


78、R1(config-subif)#encapsulation dot1Q x


//配置封装为802.1Q,并指定该子接口所对应的VLAN


79、R1(config-subif)#ip address x.x.x.x x.x.x.x


//配置该VLAN的网关地址


80、R1(config-subif)#exit


R1(config)#access-list x permit x.x.x.x


//允许来自某台主机的流量


81、R1(config)#access-list x permit x.x.x.x x.x.x.x


//允许来自某个网段的流量


82、R1(config)#access-list x deny any


//标准ACL的默认操作是拒绝所有流量


83、R1(config)#interface fastEthernet x/x


R1(config-if)#ip access-group x in


//将CAL应用在接口的入方向


84、R1(config-if)#ip access-group x out


//将ACL应用在接口的出方向


85、R1(config-if)#exit


R1(config)#line vty 0 4


R1(config-line)#access-class 1 in


//telnet远程控制,有在ACL中被允许的主机能远程telnet到本机。


86、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


//允许某个网段到某个网段的流量通过


87、R1(config)#access-list 100 permit ip host x.x.x.x host x.x.x.x


//允许某台主机到某台主机的流量通过


88、R1(config)#access-list 100 permit ip any any


//允许任何IP流量通过


89、R1(config)#access-list 100 permit tcp any any eq x


//允许某种TCP流量通过


90、R1(config)#access-list 100 permit udp any any eq x


//允许某种UDP流量通过


91、R1(config)#access-list 100 permit icmp any any


//允许ping包通过


92、R1(config)#access-list 100 deny ip any any


//扩展ACL的默认操作是拒绝所有流量


93、R1#show access-lists


//查看ACL内容及匹配情况


94、R1(config)#interface fastEthernet x/x


R1(config-if)#ip nat inside


//指定接口为NAT的inside端


95、R1(config)#interface fastEthernet x/x


R1(config-if)#ip nat outside


//指定接口为NAT的outside端


96、R1(config)#ip nat inside source list 1 interface fastEthernet x/x overload


//配置基于出接口的PAT


97、R1(config)#access-list 1 permit any


//允许任何IP作为NAT的源地址


98、R1(config)#ip nat inside source static x.x.x.x x.x.x.x


//配置静态NAT


99、R1(config)#ip nat pool spoto x.x.x.x x.x.x.x netmask 255.255.255.0


//配置NAT的地址池


100、R1(config)#ip nat inside source list 1 pool spoto overload


//配置基于地址池的PAT


101、R1(config)#ip nat inside source static tcp x.x.x.x x interface FastEthernetx/x x


//配置静态端口映射


102、R1#show ip nat translations


//查看NAT转换表


103、R1#clear ip nat translation *


//清楚NAT转换表,静态条目不会被删除


104、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封装


105、PAP认证配置,认证服务器端:


R1-S(config)#username xxx password xxx


//在认证服务器端配置本地用户名密码


106、R1-S(config-if)#ppp authentication pap


//在认证服务器端开启pap认证要求


PAP认证配置,认证客户端:


107、R1-C(config-if)#ppp pap sent-username xxx password xxx


//在认证客户端配置pap发送的用户名和密码


CHAP认证配置,认证服务器端:


108、R1-S(config)#username xxx password xxx


//在认证服务器端配置本地用户名密码


109、R1-S(config-if)#ppp authentication chap


//在认证服务器端开启chap认证要求


CHAP认证配置,认证客户端:


110、R1-C(config-if)#ppp chap hostname xxx


//在认证客户端配置chap发送的用户名


111、R1-C(config-if)#ppp chap password xxx


//在认证客户端配置chap发送的密码


112、FRSW(config)#frame-relay switching


//将路由器模拟成帧中继交换机


113、FRSW(config)#int serial x/x


FRSW(config-if)#clock rate 64000


FRSW(config-if)#encapsulation frame-relay


//将接口封装从默认的HDLC改为帧中继封装


114、FRSW(config-if)#frame-relay intf-type dce


//指定帧中继交换机接口类型为DCE


115、FRSW(config-if)#frame-relay route xxx interface serial x/x xxx


//配置帧中继交换路径


116、FRSW(config-if)#exit


FRR(config)#int serial x/x


FRR(config-if)#encapsulation frame-relay


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


117、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值


118、FRR(config-if)#exit


FRR#show frame-relay map


//查看帧中继映射表


119、FRR(config)#int serial x/x


FRR(config-if)#ip ospf network point-to-multipoint


//帧中继下OSPF默认模式是NBMA,无法自动建立邻居。手动修改网络类型为PTMP或PTP


FRR(config-if)#exit




CCNA关键知识:


1、网络模型、IP&VLSM


2、静态路由&默认路由


3、动态路由RIPv2、EIGRP、OPSF


4、VLAN、Access、Trunk、VTP、STP、单臂路由、2层交换机远程管理


5、ACL、NAT


6、WAN、PPP、Frame-Relay


7、IPv6、WLAN