NỘI DUNG:
1. Cấu hình căn bản
2. Basic System Management Configuration
3. Quit Configuration - Template
4. VLAN Trunking Protocol  - VTP
5. NAT Overload/PAT - Allow Internal Users Access To The Internet
6. Trouble shooting - show commands
  THỰC HIỆN:
1. Cấu hình căn bản
đang cập nhật...
  
2. Basic System Management Configuration
  
    Router-Cấu Hình Căn Bản
  
  conf t
hostname Router-KHANHVC
ip domain name khanhvc.lab
no ip domain-lookup
banner motd #===Router KHANHVC===#
username admin privilege 15 password itadmin
service password-encryption
 
line con 0
logging synchronous
login local
exit
line vty 0 4
login local
transport input all
crypto key generate rsa general-keys modulus 1024
ip ssh version 2
 
interface Gi0/0
no shutdown
ip address 192.168.1.254 255.255.255.0
description ===Connect to somewhere===
exit
!
end
wri   
  
  
    Với cấu hình trên chúng ta có thể dùng máy tính đặt IP trong lớp
      192.168.1.0/24 -> nối vào port Gi0/1 của router và có thể telnet/ssh
      vào thiết bị với user: admin; password: itadmin
  
  
 
  
    Switch-Cấu Hinh Căn Bản
  
  conf t
hostname Switch-KHANHVC
ip domain name khanhvc.lab
no ip domain-lookup
banner motd #===Switch KHANHVC===#
username admin privilege 15 password itadmin
service password-encryption
 
line con 0
logging synchronous
login local
exit
line vty 0 4
login local
transport input all
crypto key generate rsa general-keys modulus 1024
ip ssh version 2
!
interface Vlan1
no shutdown
description ===MGMT===
ip address 192.168.1.254 255.255.255.0
exit
end
wri   
  
  
    
    
    Với cấu hình trên chúng ta có thể dùng máy tính đặt IP trong lớp
    192.168.1.0/24 -> nối vào switch và có thể telnet/ssh vào thiết bị với
    user: 
admin; password: 
itadmin
   
 
3. Quit Configuration - Template
  
    - 1. Router
 
    - 2. Layer3
 
    - 3. Layer2
 
    - 4.1. DHCP Server
 
    - 4.2. DHCP Relay Agent
 
    - 5. Voice Data
 
  
  
    
      Router-CE-ISP Leased-Line
    
    conf t
hostname Router-CE-LL
ip domain name khanhvc.lab
no ip domain-lookup
banner motd #===Router CE Leased-Line===#
username admin privilege 15 password itadmin
service password-encryption
 
line con 0
logging synchronous
login local
exit
line vty 0 4
login local
transport input all
crypto key generate rsa general-keys modulus 1024
ip ssh version 2
 
interface et0/0
no shutdown
ip address 200.2.2.2 255.255.255.252
description ===Linked to ISP===
ip nat outside
exit
!
interface et0/1
no shutdown
ip address 100.1.1.1 255.255.255.248
description ===Linked to Firewall===
ip nat inside
exit
!
ip route 0.0.0.0 0.0.0.0 200.2.2.1
ip nat inside source list LAN-to-INTERNET interface Ethernet0/0 overload
!
ip access-list extended LAN-to-INTERNET
deny   ip 100.1.1.0 0.0.0.7 any
permit ip any any
exit
!
end
wri    
    
   
  
    
      Core Switch/Layer3 Switch
    
    conf t
hostname CoreSwitch
ip domain name khanhvc.lab
no ip domain-lookup
banner motd #===Core Switch IT Room===#
username admin privilege 15 password itadmin
service password-encryption
 
line con 0
logging synchronous
login local
exit
line vty 0 4
login local
transport input all
crypto key generate rsa general-keys modulus 1024
ip ssh version 2
!
interface Vlan1
no shutdown
description ===MGMT===
ip address 192.168.1.254 255.255.255.0
exit
vlan 100
interface Vlan100
no shutdown
description ===Server===
ip address 192.168.100.254 255.255.255.0
exit
vlan 101
interface Vlan101
no shutdown
description ===HR Dept.===
ip address 192.168.101.254 255.255.255.0
exit
!
ip routing
!
interface Ethernet0/0
no switchport
description ===Linked to Firewall===
ip address 192.168.200.2 255.255.255.248
no shutdown
exit
interface Ethernet0/1
description ===Linked to AD Server IP_100.100===
switchport mode access
switchport access vlan 100
no shutdown
exit
interface Ethernet0/2
description ===Linked to Access Switch===
switchport trunk encapsulation dot1q
switchport mode trunk
switchport trunk allowed vlan all
exit
!
ip route 0.0.0.0 0.0.0.0 200.2.2.1
!
end
wri   
    
    
      
        - 
          Nếu tạo thêm vlan thì chúng ta nhân bản vlan lên ví dụ vlan 102
        
 
      
     
    
      
      
        conf t
        vlan 102
        
          interface Vlan102
        
        no shutdown
        description ===Accc Dept.===
        
          ip address 192.168.102.254 255.255.255.0
        
        end
        wri
      
      
     
    
      
    
    
      
        
          - Nếu kết nối nhiều switch Access/Layer2 nhân bản
 
        
       
      
        
          conf t
          
            interface Ethernet0/2
          
          description ===Linked to Access Switch===
          
            switchport trunk encapsulation dot1q
          
          
            switchport mode trunk
          
          switchport trunk allowed vlan all
          end
          wri
        
        
       
      
      Tùy theo từng dòng sản phầm mà khi cấu hình port trunk CÓ THỂ CÓ hoặc
        KHÔNG có dòng "switchport trunk encapsulation dot1q"
     
    
   
 
  
    Access Switch/Layer2 Switch
  
  conf t
hostname Acc-01
ip domain name khanhvc.lab
no ip domain-lookup
banner motd #===Acc-01 HR Dept.===#
username admin privilege 15 password itadmin
service password-encryption
 
line con 0
logging synchronous
login local
exit
line vty 0 4
login local
transport input all
crypto key generate rsa general-keys modulus 1024
ip ssh version 2
!
interface Vlan1
no shutdown
description ===MGMT===
ip address 192.168.1.11 255.255.255.0
exit
!
vlan 101
interface Vlan101
no shutdown
description ===HR Dept.===
exit
!
interface Ethernet0/0
description ===Linked to Core Switch===
switchport trunk encapsulation dot1q
switchport mode trunk
switchport trunk allowed vlan all
exit
!
interface Ethernet0/1
description ===Linked to PC===
switchport mode access
switchport access vlan 101
no shutdown
exit
!
end
wri
  
  
    Tùy theo từng dòng sản phầm mà khi cấu hình port trunk CÓ THỂ CÓ hoặc
      KHÔNG có dòng "switchport trunk encapsulation dot1q"
  
  
    
    
      - 
        Nếu tạo thêm vlan thì chúng ta nhân bản vlan lên ví dụ
          vlan 102
        (vì là layer 2 nên khi tao vlan chúng ta KHÔNG đặt ip trên interface
          vlan này)
      
 
    
   
  
    
    
      
        
          conf t
          vlan 102
          
            interface Vlan102
          
          description ===Accc Dept.===
          end
          wri
         
       
    
    
   
  
  
    
      - 
        Nếu có nhiều thiết bị đầu cuối muốn gán vào
          vlan 101 chúng ta nhân
          bản lên
      
 
    
   
  
    
    
      
        
          conf t
          
            interface
            Ethernet0/2
          
          description ===Linked to PC===
          
            switchport mode access
          
          
            switchport access
            vlan 101
          
          no shutdown
          end
          wri
         
       
    
    
   
  
  
    
      - 
        HOẶC chúng ta cũng có thể cấu hình theo range interface vào vlan 101
          cũng được ví dụ từ
          port 3-9
        (tùy từng dòng sản phẩm mà phần range có thể là khác nhau tí tí)
      
 
    
   
  
    
    
      
        
          conf t
          
            interface range
            Ethernet0/3-9
          
          description ===Linked to PC===
          
            switchport mode access
          
          
            switchport access
            vlan 101
          
          no shutdown
          end
          wri
         
       
    
    
   
 
  
    DHCP Server: Trường hợp này
      dùng chính switch Core làm DHCP server
  
  conf t
ip dhcp excluded-address 192.168.101.254
ip dhcp excluded-address 192.168.101.1 192.168.101.50
!
ip dhcp pool vlan_101
network 192.168.101.0 255.255.255.0
dns-server 8.8.8.8
default-router 192.168.101.254
lease 0 0 10
end
wri
  
  
    
      - 
        Nếu muốn nhân bản cho vlan khác thì copy và chỉnh lại chổ vàng vàng
          (nếu muốn Core làm DHCP server cho vlan đó) 
      
 
    
   
  
    
      
        conf t
        
          ip dhcp excluded-address 192.168.102.254
        
        
          ip dhcp excluded-address 192.168.102.1 192.168.102.50
        
        !
        
          ip dhcp pool vlan_102
        
        network 192.168.102.0 255.255.255.0
        dns-server 8.8.8.8
        
          default-router 192.168.102.254
        
        lease 0 0 10
        end
        wri
      
      
      
   
 
  
    DHCP Relay Agent:
  
  
  
    Nếu KHÔNG dùng switch Core để cấp DHCP cho client thì chúng ta phải
    trỏ đến địa chỉ IP của DHCP bên ngoài (phải đảm bảo routing đến được server
    này thì việc xin IP mới thành công)
  
  conf t
interface Vlan101
ip helper-address 192.168.100.100
end
wri
  
    
      
      
        - 
          Nhân bản cho vlan khác: Ví dụ như
          vlan 102 muốn DHCP
          server có địa chỉ IP
          192.168.100.100 cấp
          DHCP client cho vlan này 
        
 
      
     
    
      
        
          conf t
          
            interface Vlan102
          
          
            ip helper-address
            192.168.100.100
          
          end
          wri
        
        
     
   
  
    
  
 
  
    Voice Data:
  
  
  
    Nhằm mục đích ưu tiên tín hiệu voice trước (data ưu tiên sau) để đảm bảo tín
    hiệu ít trễ nhất có thể. Áp dụng trong trường hợp máy tính cắm vào port PC
    trên IP Phone (hay PC sau điện thoại)
  
  
  
  
  conf t
interface Ethernet1/3
switchport access vlan 103
switchport voice vlan 99
end
wri
  
  
  
    
      Với cấu hình trên PC sẽ nhận ip của vlan 103, IP phone sẽ nhận ip của vlan
      99
    
  
 
4. VLAN Trunking Protocol  - VTP 
  
    - 1. VTP Server
 
    - 2. VTP Client
 
    - 3. VTP Transparent
 
  
  
    
      VTP Server Mode Thêm, sửa, xóa sau đó gửi đi để các switch khác học, và chính mode
      này cũng có thể học/đồng bộ từ các switch khác (trong trường hợp
      revision của switch khác cao hơn), và cũng có thể forward để các switch khác cùng học.
    
    
    
      
        Điều kiện:
      
      - Các đường đấu nối giữa các switch phải là trunk
      
        - Thông tin vtp giữa các switch khớp nhau: tên domain, password,
        version, ...
      
      
     
    conf t
vtp domain khanhvc.lab
vtp password vtpadmin
vtp version 2
vtp mode server
vtp pruning
end
wri
   
 
  
    VTP Client Mode Ở mode này các vtp client sẽ học các vlan từ switch khác nếu revision của
    switch khác
    cao hơn revision của nó (bản
    thân nó không được phép tạo, xóa vlan) và forward thông tin cho các switch
    khác học.
  
  
  
    Với việc triển khai VTP Server-Client thì thông tin vlan sẽ được nhất quán
    một cách tự động trên toàn hệ thống. Chúng thường được áp dụng
    triển khai cho hệ thống mới
  
    conf t
vtp domain khanhvc.lab
vtp password vtpadmin
vtp version 2
vtp mode client
end
wri
 
  
    VTP Transparent Mode Được phép
    tạo, xóa nhưng chỉ tác dụng trên local switch mà không ảnh hưởng đến các
    switch khác, không gửi thông tin của mình cho các switch khác. Tuy nhiên nó
    vẫn forward thông tin của người ta (switch khác) cho các switch sau nó học.
  
  
  
    Thông thường khi triển khai xong chúng ta thường
    chuyển về mode transparent này nếu như các bạn chưa có kiến thức tốt
    để quản lý VTP
  
  conf t
vtp domain khanhvc.lab
vtp password vtpadmin
vtp version 2
vtp mode transparent
end
wri
 
  
    5. NAT Overload/PAT - Allow Internal Users Access To The Internet
  
  
  
    Cho phép toàn các ip nằm trong Access-List 1 được phép truy cập internet và
    sử dụng IP trên cổng  Et0/2 là 125.234.102.243 làm IP đại diện
  
  conf t
interface Ethernet0/1
description ===Connect to LAN/CoreSwitch===
ip address 192.168.200.1 255.255.255.248
no shut
ip nat inside
exit
interface Ethernet0/2
description ===Connect to ISP-Router===
ip address 125.234.102.243 255.255.255.248
no shut
ip nat outside
exit
!
ip nat inside source list 1 interface Ethernet0/2 overload
!
access-list 1 permit any
!
end
wri
 
6. Trouble shooting - show commands
đang cập nhật...
7. Security 
  
    - 1. DHCP Snooping
 
    - 2. IP Source Guard
 
    - 3. DAI - Dynamic ARP Inspection
 
    - 4. Port Security
 
  
  
    
      DHCP Snooping Cho phép cổng Et0/0 cấp DHCP cho hệ thống
    
    
    conf t
! Bật DHCP Snooping và áp dụng cho VLAN 123
ip dhcp snooping
ip dhcp snooping vlan 123
! Tắt tùy chọn 82 để tránh lỗi gói tin
no ip dhcp snooping information option
! Đặt cổng tin cậy cho DHCP Server
interface Ethernet 0/0
ip dhcp snooping trust
exit
    Câu lệnh show kiểm tra
    show ip dhcp snooping
show ip dhcp snooping binding
    Debug
    debug ip dhcp snooping event
debug ip dhcp snooping packet
   
 
  
    IP Source Guard Không có phép đặt ip tĩnh ngoài SQL Server .254 và máy chấm công .251 (phải
    dùng kết hợp với DHCP Snooping mới hoạt động được)
  
    ! Cấu hình IP Source Guard trên các cổng người dùng
interface range Ethernet 0/5-10
ip verify source
exit
!
! Bật IP Source Guard trên cổng SQL Server và Máy chấm công
interface Ethernet 0/2-3
ip verify source
exit
!
! cho phép đặt ip tĩnh khi gắng vào các cổng
! Thêm Binding cho SQL Server
ip source binding a.a.a 192.168.123.250 vlan 123 interface Ethernet 0/3
! Thêm Binding cho Máy chấm công
ip source binding b.b.b 192.168.123.251 vlan 123 interface GigabitEthernet 0/2
Câu lệnh show kiểm tra
  show ip verify source
 
  
    Dynamic Arp inspection Áp dụng cống ARP Spoofing thông qua
    Dynamic ARP Inspection (phải dùng kết hợp với DHCP Snooping
    mới hoạt động được)
  
  
  ! Bật DAI cho VLAN 123
ip arp inspection vlan 123
! Đặt cổng tin cậy cho DHCP Server
interface Ethernet 0/0
ip arp inspection trust
exit
! Đặt cổng tin cậy cho SQL Server và Máy chấm công (vì đã thêm binding thủ công)
interface Ethernet 0/3
ip arp inspection trust
exit
interface Ethernet 0/2
ip arp inspection trust
exit
  
  Câu lệnh show kiểm tra
  show ip verify source
  
    Có thể tạo Access List cho phép IP tĩnh có thể hoạt động trong mạng
  
  arp access-list KHANHVC
permit ip host 192.168.123.251 mac host aabb.cc00.7000 
exit
!
ip arp inspection filter KHANHVC vlan 123
end
wri
 
  
    Port Security: Giả sử cổng Ethernet 0/5 cho phép 1 máy tính hợp l
  
  
     ! Giả sử cổng Ethernet 0/5 cho phép 1 máy tính hợp lệ:
interface Ethernet 0/5
switchport mode access
switchport port-security
switchport port-security maximum 1
switchport port-security violation restrict
switchport port-security mac-address sticky
end
  Giải thích:
  maximum 1: Chỉ cho phép 1 địa chỉ MAC trên cổng.
  violation restrict: Ghi log và chặn lưu lượng của MAC vi phạm.
  
    mac-address sticky: Tự động học địa chỉ MAC của thiết bị đầu tiên và gán vào
    cổng.
  
  
  Câu lệnh show kiểm tra
  
  
  
      show port-security
show port-security interface -nterface-id
show port-security address
show port-security violations
show mac address-table
show running-config interface -nterface-id
  
  
  Hướng khắc phục, làm bằng tay vào interface gõ shut và no shut hoặc làm tự động và cài đặt thời gian
  
  
     ! bằng tay
interface interface-id
shutdown
no shutdown
ena
!
! làm tự động
conf t
errdisable recovery cause psecure‐violation
interface e0/0
switchport port‐security aging time 2 ! sau 2 phút sẽ tự động chuyển sang up