-->

whaust

2020年11月19日 星期四

Cisco CCNA命令大全

 

登錄網路設備,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> //使用者模式,只能簡單的showping/tracer
Router>enable //從使用者模式進入特權模式
Router# //特權模式,能夠進行所有的showping/tracer
Router#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 //關閉路由功能,將路由器模擬成PC
R1(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)#ip address x.x.x.x x.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 //路徑跟蹤,查看到達目的地所經過的IP
R1(config)#router rip //運行RIP協定,進入RIP協定配置模式
R1(config-router)#version 2 //配置RIP為版本2
R1(config-router)#no auto-summary//關閉自動匯總功能
R1(config-router)#network x.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)#network x.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#show ip ospf interface //查看OSPF介面狀態資訊,包括RID、網路類型、hello時間等
C3640上載入NM-16ESW模組來對比交換機。如果是類比2層交換機,需要關閉路由功能。
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)#switchport trunk encapsulation dot1q //指定trunk封裝使用802.1Q,當交換機支援802.1QISL時使用
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-class 1 in //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 //指定介面為NATinside
R1(config)#interface fastEthernet x/x
R1(config-if)#ip nat outside //指定介面為NAToutside
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)#ppp pap sent-username xxx password xxx //在認證用戶端配置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)#encapsulation frame-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//靜態配置IPDLCI的映射關係,指定對端IP及本端使用的DLCI
FRR(config-if)#exit
FRR#show frame-relay map //查看框架轉送映射表
FRR(config)#int serial x/x
FRR(config-if)#ip ospf network point-to-multipoint //框架轉送下OSPF預設模式是NBMA,無法自動建立鄰居。手動修改網路類型為PTMPPTP
FRR(config-if)#exit

CCNA關鍵知識:
網路模型、IP&VLSM
靜態路由&預設路由
動態路由RIPv2EIGRPOSPF
VLANAccessTrunkVTPSTP、單臂路由、2層交換機遠端系統管理
ACLNAT
WANPPP
IPv6WLAN


沒有留言:

張貼留言

Popular