Tổng hợp một số lệnh CCNA Cisco cơ bản, hay dùng
tháng 3 01, 2022
Tổng hợp một số lệnh CCNA Cisco cho các anh em dùng thiết bị cisco hay học CCNA
Các lệnh CCNA phổ biến
- Lệnh Cisco truy cập vào các chế độ
- Các phím tắt thông dụng
- Lệnh cấu hình switch CISCO
- Lệnh cấu hình router Cisco
- Các lệnh đặc quyền (Privilege Commands), lệnh show trên Router
- Lệnh copy trên router Cisco
- Lệnh debug trên router Cisco
Lệnh Cisco truy cập vào các chế độ
Mô tả | Lệnh |
User mode (chế độ user) | Switch> |
Enter Privilege mode (vào chế độ đặc quyền) | Switch>enable |
Privileged mode (chế độ đặc quyền) | Switch# |
Enter configuration mode (vào chế độ cấu hình) | Switch#configure terminal |
Global Config mode | Switch(config)# |
Vào Interface mode | Switch(config)#interface fa0/1 |
Interface mode | Switch(config-if) |
Return to global configuration (Trở về Global Config) | Switch(config-if)exit |
Exit Global Config mode (Thoát Global Config) | Switch(config)#exit |
Return to user mode (Trở về user mode) | Switch#disable |
Logout (Đăng xuất) | Switch>exit |
Các phím tắt thông dụng
Mô tả | Phím tắt |
Recall Previous command (Gọi lệnh Previous) | Mũi tên lên hoặc <Ctrl> p |
Recall Next command (Gọi lệnh Next) | Mũi tên xuống hoặc <Ctrl> n |
Bắt đầu lệnh | <Ctrl> a |
Kết thúc lệnh | <Ctrl> e |
Xóa input | <Ctrl> d |
Thoát Configuration Mode | <Ctrl> z |
Làm mới output trên màn hình | <Ctrl> R |
Hoàn thành lệnh | TAB |
Lệnh cấu hình switch CISCO
Mô tả | Lệnh |
Configure device system name (Cấu hình tên thiết bị) | Switch(config)#hostname sw1 |
Sets the encrypted enable password (Thiết lập mật khẩu mã hóa) | Switch(config)#enable secret cisco |
Sets the unencrypted enable password (Đặt mật khẩu không mã hóa) | Switch(config)#enable password cisco |
Enable password encryption on all clear text password within the configuration file (mã hóa tất cả các mật khẩu trong file cấu hình) | Switch(config)#service password-encryption |
Configure a Message Of The Banner, with an ending character of $ (cài thông báo cho banner, kết thúc bằng $) | Switch(config)#banner motd $ |
Assign IP address to vlan (gán ip cho vlan) | Switch(config)#int vlan 1Switch(config-if)#ip addr 172.22.1.11255.255.255.0 |
Assign Default gateway, note the mode: gán default gateway. | Switch(config)#ip default-gateway 10.1.1.1 |
Select one interface: chọn 1 interface. | Switch(config)#int fa0/1 |
Select a range of interfaces (version dependant): chọn 1 dải interface. | Switch(config)#int range fa0/1 – 12 |
Set the interface description: Viết mô tả cho interface. | Switch(config-if)#description |
Add vlan using config mode: thêm vlan sử dụng config mode. | switch(config)#vlan 11 switch(config-vlan)#name test |
Configure Interface fa0/1 @ speed 100 Mbps and full duplex: Cấu hình int fa0/1 tốc độ 100Mbps và full duplex. | Switch(config-if)#speed 100 Switch(config-if)#duplex full |
Assign interface to vlan: gán int cho vlan. | switch(config-if)#switchport access vlan 11 |
Enable Port Security: Bật bảo mật port. | Switch(config-if)#switchport mode access Switch(config-if)#switchport port-security Switch(config-if)#switchport port-security mac-address sticky |
Disable Interface: tắt int | Switch(config-if)shutdown |
Enable Interface: cho phép int hoạt động. | Switch(config-if)no shutdown |
Configures 5 Telnet sessions each with a password of ‘cisco’: cho phép 5 phiên Telnet một lúc, mật khẩu là cisco. | Switch(config)#line vty 0 4Switch(config-line)#loginSwitch(config-line)#password cisco |
Enable and define console password of ‘cisco’: Kích hoạt và đặt mật khẩu cho console là cisco. | Switch(config)#line con 0Switch(config-line)#loginSwitch(config-line)#password cisco |
Synchronise console messages (keep what you have typing on the screen): Đồng bộ thông báo console, giữ những gì bạn đã gõ trên màn hình. | Switch(config-line)#logging synchronous |
Set the timezone and automatically adjust: Thiết lập timezone và tự động thay đổi. | Switch(config)#clock timezone gmt 0 Switch(config)#clock summer-time gmt recurring |
Sets the switch priority for the vlan: Thiết lập priority cho vlan. | Switch(config)#spanning-tree vlan 1 priority 4096 |
Enables portfast: Kích hoạt portfast. | Switch(config)#int fa0/1Switch(config-if)#spanning-tree portfast |
Enables RSTP: Bật RSTP, có tùy chọn khác là PVST và MST. | Switch(config)#spanning-tree mode rapid-pvst |
Creates a vlan: Tạo vlan. Lệnh này được thực hiện trong config mode, không phải trong vlan database và lệnh int vlan không tạo vlan. | Switch(config)#vlan 2 Switch(config-vlan)#name sales |
Assign an interface to vlan 2: Gán int cho vlan 2. | Switch(config-if)#switchport access vlan 2 |
Buộc int là trunk vô điều kiện. Có thể chọn chế độ khác là access và dynamic. | Switch(config-if)#switchport mode trunk |
Gán thủ công switch vào miền VTP. Switch tự động trở thành 1 phần của miền VTP nếu nó đang trong miền "null" và nhận VTP frame. | Switch(config)#vtp domain lab |
Thay đổi VTP mode từ chế độ mặc định là server sang client. Trong client mode thì không thay đổi được nữa. | Switch(config)#vtp mode client |
Lệnh cấu hình router Cisco
Set a console password to cisco: Đặt mật khẩu console là Cisco. | Router(config)#line con 0 Router(config-line)#login Router(config-line)#password cisco |
Set a telnet password: Đặt mật khẩu telnet. | Router(config)#line vty 0 4 Router(config-line)#login Router(config-line)#password cisco |
Stop console timing out: Console không bị log off. | Router(config)#line con 0 Router(config-line)#exec-timeout 0 0 |
Set the enable password to cisco: Đặt mật khẩu enable là cisco. | Router(config)#enable password cisco |
Set the enable secret password to peter:Đặt mật khẩu secret là peter. Mật khẩu này ghi đè lên mật khẩu enable và được mã hóa trong file cấu hình. | Router(config)#enable secret peter |
Enable an interface: Bật interface. | Router(config-if)#no shutdown |
To disable an interface: Tắt interface. | Router(config-if)#shutdown |
Set the clock rate for a router with a DCE cable to 64K: Đặt clock rate cho router với cáp DCE là 64000. | Router(config-if)clock rate 64000 |
Set a logical bandwidth assignment of 64K to the serial interface: Gán băng thông logic cho serial interface. | Router(config-if)bandwidth 64 |
To add an IP address to a interface: Thêm IP cho interface. | Router(config-if)#ip addr 10.1.1.1 255.255.255.0 |
To enable RIP on all 172.16.x.y interfaces: Bật RIP trên tất cả interface 172.16.x.y. | Router(config)#router rip Router(config-router)#network 172.16.0.0 |
Disable RIP: Tắt RIP. | Router(config)#no router rip |
To enable IRGP with a AS of 200, to all interfaces: Bật IRGP với AS 200 cho tất cả interface. | Router(config)#router igrp 200 Router(config-router)#network 172.16.0.0 |
Disable IGRP: Tắt IGRP. | Router(config)#no router igrp 200 |
Định tuyến tĩnh remote network là 172.16.1.0, với mask là 255.255.255.0, next hop là 172.16.2.1, với cost là 5 hop. | Router(config)#ip route 172.16.1.0 255.255.255.0 172.16.2.1 5 |
Disable CDP for the whole router: Tắt CDP cho cả router. | Router(config)#no cdp run |
Enable CDP for the whole router: Bật CDP cho cả router. | Router(config)#cdp run |
Disable CDP on an interface: Tắt CDP trên interface. | Router(config-if)#no cdp enable |
Enable the http server to SDM can be used: Bật http server để dùng SDM. | Router(config)#ip http server |
Defines a username and password: Đặt username (sue) và mật khẩu (cisco). Có thể dùng để xác thực PPP hoặc truy cập của người dùng. | Router(config)#username sue password cisco |
Xác định file local host trong unix, kiểu như:/etc/hosts in unix | Router(config)#ip host mypc 10.1.1.3 |
Vô hiệu hóa Disables DNS lookup. Hữu ích khi lệnh bị gõ lỗi. | Router(config)#no ip domain-lookup |
Thiết lập băng thông logic (không phải vật lý) cho interface. Thường được sử dụng bởi các giao thức định tuyến, truy vấn SNMP. | Router(config)#int s0Router(config-if)#bandwidth |
Thiết lập physical clock | Router(config-if)#clock rate 64000 |
Set the serial interface WAN encapsulation: Ngoài hdlc còn có tùy chọn khác là PPP và frame-relay. | Router(config-if)#encapsulation hdlc |
Authentication on PPP is optional: Xác thực trên PPP là tùy chọn. Lệnh này bật chap trên interface, tùy chọn khác là PAP. | Router(config-if)#ppp authentication chap |
Chọn kiểu LMI. Nếu kiểu LMI không được cấu hình đúng nó sẽ được phát hiện tự động. | Router(config-if)#frame-relay lmi-type cisco |
Định tuyến tĩnh. Kiểu định tuyến tĩnh có Administrative Distance (AD) là 1, do đó nó sẽ ghi đè lên bất kỳ định tuyến động nào. | Router(config)#ip route 50.0.0.0 255.0.0.010.1.2.1 |
Enables RIP version 1 on all LOCAL interfaces which have a 10.x.x.x address: Bật RIP v1 trên tất cả LOCAL interfaces có địa chỉ la 10.x.x.x. Enables RIP version 2: Bật RIP v2 | Router(config)#router ripRouter(config-router)#network 10.0.0.0 Router(config-router)#version 2 |
Enable the router to provide a DHCP service: Thiết lập DHCP trên router. | Router(config)#ip dhcp pool MYPOOLRouter(dhcp-config)#network 10.1.1.0 255.255.255.0Router(dhcp-config)#default-router 10.1.1.1 Router(dhcp-config)#exitRouter(config)#ip dhcp excluded-address 10.1.1.1 10.1.1.99 |
Thiết lập config register: Chỉ định việc router sẽ làm khi nó khởi động. | Router(config)#config-register 0x2102 |
Tạo sub logic interface dưới physical interface. Kích hoạt 802.1q trunking trên interface. Đặt địa chỉ IP. | Router(config)#int fa0/0.1 Router(config-subif)#encapsulation dot1Q 1 Router(config-subif)#ip address 10.1.1.1255.255.255.0 |
Bật OSPF trên bất kỳ local interface nào bắt đầu bằng địa chỉ IP 10.1.x.x. | Router(config-)#router ospf 1Router(config-router)#network 10.1.0.00.0.255.255 area 0 |
EIGRP có thể cấu hình giống với RIP hoặc sử dụng tùy chọn mask. | Router(config)#router eigrp 1Router(config-router)#network 172.16.0.0 OrRouter(config-router)#network 172.16.2.00.0.0.255 |
Thiết lập chuẩn ACL. Chuẩn này sử dụng số từ 1 đến 99. | Router(config)#access-list 1 permit172.16.1.1 |
Thiết lập Extended ACL. Địa chỉ đầu tiên là địa chỉ IP nguồn. | Router(config)#access-list 101 deny tcp host172.16.1.1 host 172.16.2.1 eq telnet Router(config)#access-list 101 permit ip any any |
Use the group command to attach an ACL to an interface: Sử dụng lệnh group để gắn ACL vào interface. | Router(config)#interface fa0/0Router(config-if)#ip access-group 1 out |
Ví dụ về sử dụng tên ACL thay vì số. | Router(config)#ip access-list extended my_listRouter(config-ext-nacl)# deny tcp host172.16.1.1 host 172.16.2.1 eq ftpRouter(config-ext-nacl)# permit ip any any |
Gán ACL cho interface bằng tên. | Router(config)#int fa0/0Router(config-if)#ip access-group my_list in |
Configuring a static NAT to allow a server to be access via the Internet, using the IP address on interface s0/0/1: Cấu hình NAT tĩnh để cho phép truy cập server qua Internet, sử dụng địa chỉ IP trên interface s0/0/1. | Router(config)#ip nat inside source static10.1.1.2 interface s0/0/1 |
Defining interface which NAT takes place between: Xác định interface mà NAT xảy ra. | Router(config)#int fa0/0.1Router(config-if)#ip nat inside |
Enables RIPng: Bật RIPng | Router(config)#ipv6 unicast-routingRouter(config)#ipv6 router rip ccnaRouter(config)#int s0/0/0Router(config-if)#ipv6 rip ccna enable |
Các lệnh đặc quyền (Privilege Commands) trên Switch
Mô tả | Lệnh |
Bật hộp thoại setup tự động khi thiết bị khởi động mà không có cấu hình. | Switch#setup |
Displays the config held in DRAM. Which is lost if not copy run start command is not used: Hiển thị cấu hình lưu trong DRAM. Cấu hình này bị mất khi lệnh not copy run start không được sử dụng. | Switch#show running-config |
Displays the NVRAM (None volatile) config: Hiển thị cấu hình NVRAM. | Switch#show startup-config |
Saves the config: Lưu cấu hình, nếu không có lệnh này tất cả các thay đổi, cấu hình sẽ bị mất. | Switch#copy running-config startup-config |
Saves the running config to a TFTP server: Lưu cấu hình đang chạy vào TFTP server. | Switch#copy running-config tftp |
Copies IOS files to a TFTP server: Sao chép file IOS vào TFTP server. | Switch#copy flash tftp |
Copies files from a TFTP server the device flash: Copy file từ TFTP vào thiết bị flash. | Switch#copy tftp flash |
Erase the config held in NVRAM: Xóa cấu hình lưu trong VNRAM. Nếu thực hiện lệnh này kèm với reload thì tất cả cấu hình sẽ bị mất. | Switch#erase startup-config |
Reboots the device: Khởi động lại switch. | Switch#reload |
Abort sequence: Hủy một lệnh, thủ tục | <Shift> <Ctrl> 6 |
Suspend Telnet Session: Tạm dừng phiên telnet | Nhấn cùng lúc <Shift> <Ctrl> 6, thả hết các phím ra và nhấn ngay x |
Show the current sessions: Xem phiên hiện tại, phiên nào có * là phiên hiện hoạt. | Switch#show sessions |
Forcible closes a telnet session: Buộc đóng một phiên telnet. | Switch#disconnect |
Set the device local clock: Thiết lập giờ địa phương cho thiết bị. Lệnh này không được thực hiện trong chế độ cấu hình. | Switch#clock set 10:00:00 april 2 2008 |
Display the IOS version along with other useful info: Xem phiên bản IOS và các thông tin hữu ích khác như uptime hệ thống, cấu hình register... | Switch#show version |
Xem nội dung file của flash. | Switch#show flash |
Xem giờ. | Switch#show clock |
Xem user hiện đang đăng nhập. | Switch#show users |
By default displays the last 10 commands: Xem 10 lệnh vừa dùng. | Switch#show history |
Displays the ARP cache: Xem cache ARP. | Switch#show arp |
Displays the spanning tree status on vlan 1: Xem trạng thái spanning tree trên vlan 1. | Switch#show spanning-tree vlan 1 |
Lists all the configured vlans: Liệt kê tất cả vlan đã cấu hình. | Switch#show vlan |
Displays VTP info such as VTP mode, VTP domain, VTP counter: Xem thông tin VTP như chế độ, miền, bộ đếm. | Switch#sh vtp status |
Ping selected address: Ping một địa chỉ IP. | Switch#ping 10.1.1.1 |
Extended ping: Phải thực hiện trong chế độ privilege. | Switch#ping |
Display the interface status: Hiển thị trạng thái interface. | Switch#show int fa0/1 |
Displays the vlan status and the IP address VLAN 1 (often the management vlan): Xem trạng thái VLAN 1. | Switch#show interfaces vlan 1 |
Displays a list of CDP neighbours: Xem danh sách CDP. | Switch#show cdp neighbors |
Extended information on the above: Xem nhiều thông tin hơn lệnh trên. | Switch#show cdp neighbors details |
Display CDP packets as they arrive: Xem các gói CDP khi chúng đến. | Switch#debug cdp packets |
Display ping packets as they arrive: Hiển thị các gói ping khi chúng đến. | Switch#debug icmp packets |
Display switch MAC Addresses table. These entries are learnt from the source mac address in the Ethernet frames: Xem bảng địa chỉ MAC, lấy từ địa chỉ MAC nguồn trong Ethernet frame. | Switch#show mac address-table |
Các lệnh đặc quyền (Privilege Commands), lệnh show trên Router
Yêu cầu | Lệnh Cisco |
Vào chế độ đặc quyền | enable |
Trở về user mode từ privileged | disable |
Thoát router | logout/exit/quit |
Xem phiên bản router | Router#show version |
Xem cấu hình hiện tại (DRAM) | Router#show running-config |
Xem cấu hình startup (NVRAM) | Router#show startup-config |
Xem dung lượng file IOS, flash | Router#show flash |
Xem tất cả log router ghi lại. | Router#show log |
Xem trạng thái interface của interface e0 | Router#show interface e0 |
Displays the interface operational status and IP addresses for all router interfaces: Xem trạng thái hoạt động của interface và địa chỉ IP cho tất cả các interface router. | Router#show ip interface brief |
Xem kiểu cáp trên s0 | Router#show controllers 0 |
Xem các thiết bị cdp đã kết nối | Router#show cdp neighbor |
Xem thông tin chi tiết trên tất cả các thiết bị | Router#show cdp entry * |
Displays all the configured routing protocols: Xem tất cả các giao thức định tuyến đã được cấu hình. | Router#show ip protocols |
Displays the IP routeing table: Hiển thị bảng định tuyến IP. | Router#show ip route |
Hiển thị access list | Router#show access-lists |
Xem router nào thấy được switch ISDN | Router#show isdn status |
Displays the NAT translations: Xem các NET translation. | Router#show ip nat translations |
Xem cấu hình cáp vật lý:DTE/DCE, x.21, V.35,RS232 | Router#show controllers s 0 |
Displays the end-to-end status: Hiển thị trạng thái end-to-end | Router#show frame-relay pvc |
Displays the type of LMI and the number LMI frames: Xem kiểu LMI và số khung LMI. | Router#show frame-relay lmi |
Displays the frame relay inverse ARP table: Hiện thị bảng frame relay inverse ARP. | Router#show frame-relay map |
Xem danh sách ospf neighbor và trạng thái của chúng | Router#show ip ospf neighbor |
Xem trạng thái interface ospf. | Router#show ip ospf interface |
Xem danh sách eigrp neighbor và trạng thái của chúng. | Router#show ip eigrp neighbor |
Xem trạng thái interface EIGRP. | Router#show ip eigrp interface |
Xem tất cả trunk port trên thiết bị | Router#show interface trunk |
ping IPv6 | Router#ping 2000:1000:500:3::1 |
Lệnh copy trên router Cisco
Yêu cầu | Lệnh Cisco |
---|---|
Lưu cấu hình hiện tại từ DRAM vào NVRAM | copy running-config startup-config |
Hợp nhất cấu hình NVRAM vào DRAM | copy startup-config running-config |
Sao chép cấu hình DRAM vào TFTP server | copy runing-config tftp |
Hợp nhất cấu hình TFTP với cấu hình router hiện tại lưu trên DRAM | copy tftp runing-config |
Sao lưu IOS lên TFTP server | copy flash tftp |
Nâng cấp router IOS từ TFTP server | copy tftp flash |
Lệnh debug trên router Cisco
Yêu cầu | Lệnh Cisco |
---|---|
Bật debug cho RIP | debug ip rip |
Xem thông tin debug IGRP tóm tắt | debug ip igrp events |
Xem thông tin debug IGRP chi tiết | debug ip igrp transactions |
Debug IPX RIP | debug ipx routing activity |
Debug IPX SAP | debug IPX SAP |
Bật debug cho CHAP hoặc PAP | debug ppp authentication |
Tắt tất cả debug | no debug allundebug all |
Theo