Tải bản đầy đủ (.docx) (19 trang)

Tổng Hợp Các Câu Lệnh Cấu Hình Lab CCNA (Cisco Certified Network Associate)

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (158.11 KB, 19 trang )

Mạng máy tính và truyền thông

CCNAX

CCNA
LAB CONFIGURATION
MỤC LỤC

1


Mạng máy tính và truyền thông

1.

Cấu hình cơ bản Router

enable
configure terminal
hostname Xikos
banner motd #Welcome Home#
//Cấu hình tên, lời chào
enable password cisco
enable secret vnpro
//Cấu hình Password vào Router
line console 0
password cisco
exit
line vty 0 4
password vnpro
exit


//cấu hình Password Telnet (Số kết nối: vty 1, vty 0 4, vty 0 15)
interface f0/0
ip address 192.168.1.1 255.255.255.0
no shutdown
exit
interface s1/0
ip address 192.168.12.1 255.255.255.252
no shutdown
//Cấu hình địa chỉ IPv4 (IP + Netmask)cho các interface
 Ta có thể cấu hình mô tả chức năng cho Interface với lệnh:
interface f0/0
description Ket Noi Chinh
 Kiểm tra thông tin cấu hình và sao lưu
show interface f0/0
show ip interface brief
show running-config
// Xem thông tin Interface
wr
copy running-config startup-config
//Sao lưu cấu hình
 Mã hóa mật khẩu và thiết lập thời gian Logout
configure terminal
service password-encryption
//Mã hóa mật khẩu bằng MD7
line console 0
exec-timeout 20 0
//Tự động Logout sau 20s rãnh rỗi
 Xóa cấu hình cũ và khởi động lại Router
erase startup-config
2



Mạng máy tính và truyền thông

reload
//Xóa cấu hình và khởi động lại
no ipdomain-lookup
//Vô hiệu phân giải lệnh hoặc ta có thể dùng Ctrl + Shift + 6
 Xem thông tin các thiết bị lân cận
show cdp neighbors
show cdp entry *
show cdp traffic
show cdp interface
 Telnet điều khiển từ xa Router
telnet 192.168.1.1
//Router cần phải cấu hình Password vty để đăng nhập điều khiển
username Xikos password abc123
username Noris password def456
line vty 0 15
login local
//Tạo các User để đăng nhệp vào điều khiển
show user
clear line 99
//Xem những ai đang điều khiển thiết bị và đóng kết nối điều
khiển từ ai đó
show session
//Xem thiết bị đang điều khiển những ai

2.


Cấu hình giả lập Router thành PC

configure terminal
no ip routing
ip default-gateway 192.168.1.1
interface f0/0
ip address 192.168.1.10 255.255.255.0
no shutdown
exit
//Vô hiệu Routing, cấu hình IP và Default-Gateway

3.

Static Route

configure terminal
ip route 192.168.1.0 255.255.255.0 192.168.12.1
//ip route [Net cần học] [IP in-going next hop]
ip route 192.168.1.0 255.255.255.0 f0/1
//Dùng Interface in-going next hop cũng được

3


Mạng máy tính và truyền thông

ip route 192.168.1.0 255.255.255.0 f0/1 10
//Thêm chỉ số AD để xác định đường Route chính, phụ
show ip route
//Kiểm tra bảng định tuyến


4.

Default Root

configure terminal
ip route 0.0.0.0 0.0.0.0 192.168.12.2
//ip route 0.0.0.0 0.0.0.0 [IP in-going next hop] – có thể thay
bằng Interface
ping 192.168.1.1
ping 192.168.1.1 repeat 1000
traceroute 192.168.30.1
traceroute 192.168.30.1 probe 100
//Kiểm tra kết nối và đường Route

5.

DHCP

configure terminal
ip dhcp pool Net.1
network 192.168.1.0 255.255.255.0
default-router 192.168.1.1
dns-server 192.168.1.1
lease 0 24
//Tạo Pool mạng cấp phát IP động với lớp mạng cần cấp IP và
Default-Gateway của nhóm Host cần cấp IP
ip dhcp excluded-address 192.168.1.1 192.168.1.50
//Loại ra những IP đặc biệt chỉ đặt tĩnh
 Cấu hình DHCP Relay Agent cho các vùng mạng

configure terminal
interface f0/0
ip helper-address 192.168.3.1
//Vào Interface Default Gateway của vùng mạng (Interface nhận
Broadcast trực tiếp) cấu hình ip helper-address [IP DHCP Server].
Phải cấu hình định tuyến giữa các mạng để cấp phát IP, ta có thể
dùng bất kì IP Adrress Interface của DHCP Server.
 Cấu hình PC nhận IP từ DHCP
configure terminal
interface f0/0
ip address dhcp
 Kiểm tra DHCP
show ip dhcp pool
show ip dhcp binding
show ip interface brief
4


Mạng máy tính và truyền thông

6.

RIP

configure terminal
router rip
version 2
network 10.0.0.0
network 172.16.0.0
network 192.168.1.0

network 192.168.12.0
//Dùng RIPv2 và cấu hình địa chỉ mạng theo lớp A, B, C ứng với
các kết nối trực tiếp
 Vô hiệu truyền nhận thông tin định tuyến
configure terminal
router rip
passive-interface f0/0

7.

EIGRP

configure terminal
router eigrp 1
network 10.0.0.0
network 192.168.12.0
//Cấu hình EIGRP với chỉ số AS phải đồng nhất, cấu hình địa chỉ
mạng theo lớp
 Cấu hình băng thông Interface
configure terminal
interface f0/0
duplex full
speed 100
bandwidth 100000
 Kiểm tra EIGRP
show ip route
show ip eigrp topology
 Cấu hình Load Balancing
configure terminal
router eigrp 1

variance 3
 Cấu hình Update Route bằng Unicast
configure terminal
router eigrp 1
5


Mạng máy tính và truyền thông

neighbor 192.168.12.1 f0/0
neighbor 192.168.13.3 f0/1
//neighbor [IP Next-hop] [Interface Out-Bound]
 Cấu hình Summary cho các Subnet VLSM
configure terminal
interface f0/0
ip summary-address eigrp 1 10.2.0.0 255.255.0.0
//Vào Interface out-goning của Router quản lý vùng mạng để cấu
hình Summary, tăng khả năng phân biệt cho các subnet (Cấu hình
chi tiết thêm một octet)

8.

OSPF

configure terminal
router ospf 1
network 192.168.1.1 0.0.0.255 area 0
network 172.16.31.1 0.0.255.255 area 0
//Cấu hình AS đồng nhất, cấu hình địa chỉ Interface kết nối trực
tiếp kèm Wildcard Mask và area tương ứng, các Router cùng area

phải cấu hình giống số area với nhau
 Kiểm tra
show
show
show
show

ip
ip
ip
ip

route
ospf neighbor
protocol
ospf interface brief

 Cấu hình Router ID (IP đại diện)
configure terminal
router ospf 1
router-id 1.1.1.1
exit
clear ip ospf proces //Cấu hình router-id nào lớn nhất sẽ làm DR
 Cấu hình xác thực Key bảo mật
configure terminal
interface f0/0
ip ospf authentication-key vnpro
exit
router ospf 1
area 0 authentication

//Cấu hình xác thực trên các interface của Router
 Cấu hình DR/BDR tĩnh
6


Mạng máy tính và truyền thông

configure terminal
interface f0/0
ip ospf priority 255
shutdown
no shutdown
//Cấu hình độ ưu tiên cao nhất để đặt cho Router hiện tại là DR
 Cấu hình tự động học Default Route cho các Router cùng giao thức OSPF
configure terminal
router ospf 1
default-information originate
//Cấu hình tương tự cho RIP, EIGRP thay router ospf 1 tương ứng
 Cấu hình ASBRs tiếp xúc giữa 2 area khác giao thức định tuyến (External route - Một Router
cấu hình cả OSPF, RIP, EIGRP)
configure terminal
router ospf 1
redistribute rip subnets
redistribute eigrp subnets
redistribute static subnets
 Cấu hình ABR Totally Stub
configure terminal
router ospf 1
area 1 stub
//Cấu hình tất cả Router trong khu vực (Internal) area 1 stub

configure terminal
router ospf 1
area 1 stub no-summary
//Cấu hình Router ABRs biên

9.

Access List Control

 Cấu hình Access List Standard
configure terminal
access-list 1 deny 172.16.4.0 0.0.255.255 log
access-list 1 permit 192.168.12.0 0.0.0.255
//Tạo ACL Standard, ghi lại Log cho mỗi lần chặn
interface f0/0
ip access-group 1 out
interface f0/1
ip access-group 1 in
exit
//Xác định chiều In và Out trên Interface để gọi

7


Mạng máy tính và truyền thông

show access-list
no access-list 1
//Xem và xóa access list, mỗi lần sửa ACL Standard là phải xóa đi
làm lại


 Cấu hình Access list Extended
configure terminal
access-list 101 deny tcp 172.16.4.0 0.0.0.255 172.16.3.0
0.0.0.255 eq 23 log
access-list 101 deny tcp 172.16.4.0 0.0.0.255 eq 23 172.16.3.0
0.0.0.255
access-list 101 deny icmp any any
access-list 101 permit any any
//Tạo ACL Extended chặn Telnet và bị Telnet, chặn Ping
interface f0/0
ip access-group 101 out
exit
//Xác định chiều In và Out trên Interface để gọi
show access-list
no access-list 101
//Xem và xóa access list, mỗi lần sửa là phải xóa đi làm lại
 Cấu hình Named Access List
configure terminal
ip access-list extended Game //Có thể thay bằng standard
deny tcp 172.16.4.0 0.0.0.255 172.16.3.0 0.0.0.255 eq 23 log
permit tcp 172.16.3.0 0.0.0.255 172.16.4.0 0.0.0.255 eq 80
//Tạo Named ACL ta có thể sửa xóa dễ dàng hơn
interface f0/0
ip access-group Game out
exit
//Xác định chiều In và Out trên Interface để gọi
show access-list
ip access-list extended Game
15 permit tcp 192.168.1.0 0.0.0.255 172.16.3.0 0.0.0.255 eq 25

//Tùy theo thứ tự mà ta chọn số thíc hợp để thêm ACL
show access-list
ip access-list extended Game
no 15 permit tcp 192.168.1.0 0.0.0.255 172.16.3.0 0.0.0.255 eq 25
8


Mạng máy tính và truyền thông

15 permit tcp 192.168.12.0 0.0.0.255 172.16.3.0 0.0.0.255 eq 25
//Chỉnh sửa ACL
 Cấu hình cho phép một mạng hay một vùng mạng Telnet
ip access-list standard Admin
permit 192.168.2.0 0.0.0.3
exit
//Cấu hình Standard ACL Named chỉ cho Admin được Telnet, còn lại
ta sẽ chặn trong ACL khác
line vty 0 15
access-class in
//Cấu hình cho phép Telnet phải trên VTY chứ không phải trên
Interface
-

10.

Standard đặt ACL gần đích, Extended đặt ACL gần nguồn

NAT

 Cấu hình Static NAT

configure terminal
ip route 0.0.0.0 0.0.0.0 200.0.0.2
router ospf 1
default-information originate
exit
//Cấu hình Default Route tới ISP
ip nat inside source static 192.168.1.11 200.200.200.200
ip nat inside source static 192.168.1.12 200.200.200.201
// ip nat inside source static [IP mạng Privated] [IP Public NAT]
interface f0/0
ip nat inside //Interface mạng nội bộ
exit
interface f0/1
ip nat outside //Interface mạng Public
exit
//Gọi Nat trên các Interface Router
configure terminal
ip route 200.200.200.200 255.255.255.255 200.0.0.1
ip route 200.200.200.201 255.255.255.255 200.0.0.1
//Cấu hình trên ISP để mạng bên ngoài vào được bên trong
 Cấu hình Dynamic NAT
configure terminal
9


Mạng máy tính và truyền thông

ip route 200.200.200.0 255.255.255.252 200.0.0.1
//Cấu hình trên ISP vùng mạng Public
access-list 1 permit 192.168.1.0 0.0.0.255

//Xác định vùng mạng được NAT
ip nat pool DYNA-NAT 200.200.200.1 200.200.200.2 netmask
255.255.255.252
ip nat inside source list 1 pool DYNA-NAT
//Trên Router Quy định những Public IP dùng để NAT ra ngoài
interface f0/0
ip nat inside
exit
interface f0/1
ip nat outside exit
//Gọi Nat trên các Interface Router
show ip nat static
show ip nat translation
//Kiểm tra thông tin NAT
 Cấu hình PAT (Overload NAT)
configure terminal
access-list 1 permit
access-list 1 permit
ip nat inside source
//Xác định mạng được

192.168.1.0 0.0.0.255
192.168.3.0 0.0.0.255
list 1 int f0/1 overload
PAT và cấu hình Overload

interface f0/0
ip nat inside
exit
interface f0/1

ip nat outside exit
//Gọi Nat trên các Interface Router, Router sẽ dùng chính IP
Public của nó để chuyển đổi
 Cấu hình NAT Port
configure terminal
ip nat inside source static tcp 192.168.1.11 23 int f0/1 2323
ip nat inside source static tcp 192.168.1.12 23 int f0/1 4545
//Cấu hình NAT Port
ping 192.168.1.11 2323
telnet 192.168.1.12 4545
//Kiểm tra kết nối

11.

VLAN – Trunking
10


Mạng máy tính và truyền thông

configure terminal
vlan 2
name VL1
vlan 3
name VL2
exit
interface range f0/1-5
switchport access vlan 2
exit
interface range f0/6-12

switchport access vlan 3
exit
//Tạo VLAN và thêm Port vào VLAN trên Switch, VLAN 1 là mặc định
không tạo thêm
interface g0/1
switchport mode trunk
//Cấu hình trunking cho Port
 Kiểm tra VLAN, Trunking
show vlan brief
show interface trunk
 Cấu hình Sub Interface cho Router kết nối các VLAN
configure terminal
interface f0/0
no shutdown
exit
interface f0/0.2 //Tùy chọn Sub Interface
ip address 192.168.2.1 255.255.255.0
encapsulation dot1Q 2 //Tương ứng số VLAN
exit
interface f0/0.3
ip address 192.168.3.1 255.255.255.0
encapsulation dot1Q 3
exit
show ip interface brief
//Kiểm tra Interface, kết nối giữa các VLAN không cần cấu hình
định tuyến vì chỉ có một Router kết nối trực tiếp các mạng rồi
 Cấu hình cơ bản Switch Layer 3
configure terminal
ip routing
interface f0/0

no switchport
ip address 192.168.1.1 255.255.255.0
11


Mạng máy tính và truyền thông

no shutdown
//Cấu hình địa chỉ cho Interface
router ospf 1
network 192.168.1.0 0.0.0.255 area 0
//Cấu hình định tuyến giống như Router, chú ý ip routing
 Cấu hình Switch Layer 3 kết nối các VLAN
configure terminal
ip routing
vlan 2
name VL1
vlan 3
name VL2
exit
//Tạo các VLAN trên SW L3 như đã cấu hình trên SW L2
interface g0/1
//Interface kết nối tới Switch, thường chỉ có một kết nối
switchport mode trunk
switchport trunk encapsulation dot1Q
exit
//Cấu hình Trunking trên Switch L3
interface vlan 2
ip address 192.168.1.1. 255.255.255.0
interface vlan 3

ip address 192.168.2.1 255.255.255.0
exit
//Cấu hình IP Default Gateway cho các VLAN

12.

VTP

configure terminal
interface range g0/1-2
switchport mode trunk
//Cấu hình Trunk trên các Switch để các Client trao đổiVLAN
vtp domain VNPRO
vtp mode server
vtp password abc123
//VTP Server cung cấp thông tin cho client
vtp domain VNPRO
vtp mode client
vtp password abc123
//VTP Client (Cấu hình trên Switch khác)
vtp domain VNPRO
12


Mạng máy tính và truyền thông

vtp mode transparent
//VTP Transparent riêng biệt
 Kiểm tra
show vtp status

show vlan brief

13.

SSH – Port Security

 Cấu hình chỉ dùng SSH
configure terminal
ip domain-name alias.net
username abc password 123
crypto key genarate rsa
line vty 0 4
login local
transport input ssh
exit
ip ssh version 2
 Cấu hình Port Security trên Switch
configure terminal
spanning-tree portfast
interface range f0/5-12
switchport mode access
switchport port-security
switchport port-security
switchport port-security
switchport port-security
//Cấu hình Port Security

maximum 1
mac-address sticky
violation shutdown

chỉ cho phép học một MAC

show port-security address
show port-security interface f0/5
show interface status
show mac address-table
//Kiểm tra

14.

EtherChannel

configure terminal
interface range f0/1-4
switchport mode trunk
//Cấu hình Trunk trước tiên
interface range f0/1-2
channel-group 1 mode active
//Cấu hình LACP
13


Mạng máy tính và truyền thông

interface range f0/1-2
switchport mode trunk
channel-group 1 mode active
//Trên Switch láng giềng cấu hình tương tự, lưu ý Active-Active
và Active-Stanby
interface range f0/3-4

channel-protocol pagp
channel-group 2 mode desirable
//Cấu hình PAGP
interface range f0/1-2
switchport mode trunk
channel-group 2 mode desirable
//Trên Switch láng giềng cấu hình desirable-desirable
 Kiểm tra
show interface port-channel
show etherchannel summary
show etherchannel port-channel

15.

HSRP

 Cấu hình HSRP cơ bản
configure terminal
interface f0/0 //Interface kết nối tới các host access
standby 1 name Link_1
standby 1 ip 192.168.2.1 //IP ảo
standby 1 priority 120 //Xác định Router Active, mặc định 100
standby 1 preemt //Đòi lại quyền Active – Standby
standby 1 timers 4 12 //Gấp 3
standby 1 authentication abc123 //Xác thực Key bảo mật
standby 1 track f0/1 50 //Kiểm tra đầu xa nếu Down thì trừ
Priority 50
//Cấu hình trên Router Active
configure terminal
interface f0/0

standby 1 name Link_2
standby 1 ip 192.168.2.1
standby 1 priority 100 //Priority phải nhỏ hơn Active
standby 1 preemt
standby 1 timers 4 12
standby 1 authentication abc123
//Cấu hình trên Router Standby, Router cuối cùng không cần track
show standby brief
//Kiểm tra

14


Mạng máy tính và truyền thông

 Cấu hình HSRP Multigroup
configure terminal
interface f0/0
no shutdown
exit
interface f0/0.2
encapsulation dot1Q 2
ip address 192.168.2.2 255.255.255.0
standby 1 name Link_1
standby 1 ip 192.168.2.1
standby 1 priority 120
standby 1 preemt
interface f0/0.3
encapsulation dot1Q 3
ip address 192.168.3.2 255.255.255.0

standby 1 name Link_2
standby 1 ip 192.168.3.1
standby 1 preemt
//Cấu hình trên Router và định tuyến các mạng
configure terminal
interface f0/0
no shutdown
exit
interface f0/0.2
encapsulation dot1Q 2
ip address 192.168.2.3 255.255.255.0
standby 1 name Link_1
standby 1 ip 192.168.2.1
standby 1 preemt
interface f0/0.3
encapsulation dot1Q 3
ip address 192.168.3.3 255.255.255.0
standby 1 name Link_2
standby 1 ip 192.168.3.1
standby 1 priority 120
standby 1 preemt
//Cấu hình trên Router còn lại và định tuyến các mạng
-

16.

Trên Switch ta chia VLAN, gán Port và cấu hình trunking

GLBP


configure terminal
interface f0/0 //Interface kết nối Host access
glbp 1 ip 192.168.2.1 //IP ảo
glbp 1 priority 120
glbp 1 preempt
glbp 1 timer 4 12
15


Mạng máy tính và truyền thông

//Cấu hình trên Router chính
configure terminal
interface f0/0 //Interface kết nối Host access
glbp 1 ip 192.168.2.1 //IP ảo
glbp 1 priority 110
glbp 1 preempt
glbp 1 timer 4 12
//Cấu hình trên Router phụ
interface f0/0
glbp 1 load-balancing round-robin
exit
clear arp-cache
//Cấu hình Load Balacing đều
interface f0/0
glbp 1 load-balancing weighted
glbp 1 weighting 200
exit
clear arp-cache
//Cấu hình Load tỉ lệ 2:1, tương ứng cấu hình cho Router còn lại


17.

Frame Relay

 Cấu hình ISP Frame Relay
configure terminal
frame-relay switching
interface s1/0
no ip address
no shutdown
encapsulation frame-relay
clock rate 56000
frame-relay intf-type dce
frame-relay route 102 interface s1/1 201
//DLCI Router đi qua Interface s1/1 tới DLCI Next
frame-relay route 103 interface s1/2 301
//Cấu hình trên các Interface của Frame Relay Switch giả lập ISP
 Cấu hình Frame Relay Point-to-Point trên các Router
configure terminal
interface s1/0 //Interface kết nối tới ISP
no ip address
no shutdown
encapsulation frame-relay
interface s1/0.123 point-to-point
ip address 10.1.1.6 255.255.255.0
frame-relay interface-dlci 102
16



Mạng máy tính và truyền thông

no shutdown
 Cấu hình Frame Relay Multipoint trên các Router
configure terminal
interface s1/0 //Interface kết nối tới ISP
no ip address
no shutdown
encapsulation frame-relay
interface s1/0.123 multipoint
ip address 192.168.123.1 255.255.255.0
ip ospf network broadcast
frame-relay map ip 192.168.123.2 102 broadcast //IP Next Hops
nhưng DLCI của Router
frame-relay map ip 192.168.123.3 103 broadcast

18.

VPN – IPSec

 Cấu hình Tunnel
configure terminal
interface tunnel600
tunnel source 118.118.118.2
tunnel destination 118.118.118.6
keepalive 5 1
ip address 192.168.12.1 255.255.255.252
//Cấu hình Tunnel giữa 2 Router, xác định địa chỉ nguồn và đích,
cấu hình đại chỉ tunnel
 Cấu hình IPSec

configure terminal
crypto isakmp enable
crypto isakmp policy 10
authentication pre-share
encrypt des
hash md5
group 2
exit
//Quy ước chính sách mã hóa
crypto isakmp key cisco address 118.118.118.6 //Next Hops
crypto ipsec transform-set MYSET esp-md5-hmac esp-des
mode tunnel
exit
crypto ipsec security-association lifetime second 1800
access-list 106 permit gre host 118.118.118.2 host 118.118.118.6
//Tạo chính sách MYSET và xác định mạng thiết lập kết nối
17


Mạng máy tính và truyền thông

crypto map MYMAP 10 ipsec-isakmp
match address 106
set peer 118.118.118.6 //Next hops
set transform-ser MYSET
exit
//Thống nhất thành một chính sách lớn
interface f0/1
crypto map MYMAP
//Gọi IPSec trên Interface

 Kiểm tra
sh crypto isakmp sa
sh crypto ipsec sa
sh crypto engine connections active

19.

IPV6

configure terminal
interface f0/0
ipv6 address 2011:db8:1::1/64
no shutdown
exit
//Cấu hình IP trên Interface
ipv6 route ::/0 f0/1 2001:db8:1::1
//Default Route
ipv6 route 2001:db8:3::/64 tunnel600 2201:db8:13::12
//ipv6 route [Mạng cần học] [Kênh thông qua] [IP in-going Next
hop]
ipv6 unicast-routing
ipv6 router ospf 1
router-id 0.0.0.1
interface f0/0
ipv6 ospf 1 area 0
interface f0/1
ipv6 ospf 1 area 0
//Cấu hình OSPFv3
ipv6 unicast-routing
ipv6 router rip vnpro

interface f0/0
ipv6 rip vnpro enable
interface f0/1
ipv6 rip vnpro enable
18


Mạng máy tính và truyền thông

ipv6 router rip vnpro
maximum-paths 1
//Cấu hình RIPng

20.

Cấu hình quản trị mạng

 SNMP
configure terminal
snmp-server community cisco RW //RO
 Syslog
configure terminal
logging 192.168.1.10 //PC làm quản trị
trap debug
logging trap information

 Netflow
configure terminal
interface f0/0
ip flow ingress

ip flow egress
exit
ip flow-export destination 192.168.1.10 9996 //IP quản trị và
Port
ip flow-export version 9
show ip flow export
show ip cache flow
//Kiểm tra

19



×