Bảo Mật Truy Cập Switch
I. 🔐 Giới thiệu Port Security
Port Security là một cơ chế bảo mật đơn giản nhưng hiệu quả cho phép kiểm soát truy cập vào switch dựa trên địa chỉ MAC.
II. ⚙️ Các bước cấu hình cơ bản
1. Bật Port Security trên cổng switch:
bash
Copy
Edit
Switch(config-if)# switchport port-security
2. Cấu hình số lượng địa chỉ MAC tối đa được phép:
Switch(config-if)# switchport port-security maximum <1-1024>
Switch(config-if)# switchport port-security mac-address <MAC-addr>
4. Bật tính năng học địa chỉ MAC động và lưu lại:
Switch(config-if)# switchport port-security mac-address sticky
III. 🛡️ Chế độ xử lý vi phạm (violation modes)
Switch(config-if)# switchport port-security violation {shutdown | restrict | protect}
IV. 📋 Ví dụ cấu hình đầy đủ Port Security
interface FastEthernet0/10 switchport access vlan 10 switchport mode access switchport port-security switchport port-security maximum 1 switchport port-security violation shutdown switchport port-security mac-address sticky spanning-tree portfast
V. 🔍 Kiểm tra trạng thái Port Security
Switch# show port-security interface fastEthernet0/10
🧾 Kết quả mẫu:
Port Security : Enabled Port Status : Secure-shutdown Violation Mode : shutdown Maximum MAC Addresses : 1 Sticky MAC Addresses : 1 Last Source Address : 0003.a089.efc5 Security Violation Count : 1
I. 🔐 Giới thiệu Port Security
Port Security là một cơ chế bảo mật đơn giản nhưng hiệu quả cho phép kiểm soát truy cập vào switch dựa trên địa chỉ MAC.
✅ Dùng để ngăn chặn người dùng lạ hoặc thiết bị trái phép cắm vào switch trong các mạng nội bộ.
II. ⚙️ Các bước cấu hình cơ bản
1. Bật Port Security trên cổng switch:
bash
Copy
Edit
Switch(config-if)# switchport port-security
2. Cấu hình số lượng địa chỉ MAC tối đa được phép:
Switch(config-if)# switchport port-security maximum <1-1024>
Mặc định chỉ cho phép 1 địa chỉ MAC trên mỗi cổng.
3. Chỉ định trước địa chỉ MAC được phép:Switch(config-if)# switchport port-security mac-address <MAC-addr>
4. Bật tính năng học địa chỉ MAC động và lưu lại:
Switch(config-if)# switchport port-security mac-address sticky
Địa chỉ MAC học được sẽ được ghi nhớ vào cấu hình đang chạy (running-config).
III. 🛡️ Chế độ xử lý vi phạm (violation modes)
Switch(config-if)# switchport port-security violation {shutdown | restrict | protect}
shutdown | (mặc định) Tắt cổng, vào trạng thái err-disabled. |
restrict | Cổng vẫn hoạt động, drop các frame vi phạm, gửi SNMP/syslog. |
protect | Drop các frame vi phạm, không log và không SNMP. |
✋ Với shutdown, cần dùng shutdown và no shutdown hoặc cấu hình errdisable recovery để mở lại port.
IV. 📋 Ví dụ cấu hình đầy đủ Port Security
interface FastEthernet0/10 switchport access vlan 10 switchport mode access switchport port-security switchport port-security maximum 1 switchport port-security violation shutdown switchport port-security mac-address sticky spanning-tree portfast
V. 🔍 Kiểm tra trạng thái Port Security
Switch# show port-security interface fastEthernet0/10
🧾 Kết quả mẫu:
Port Security : Enabled Port Status : Secure-shutdown Violation Mode : shutdown Maximum MAC Addresses : 1 Sticky MAC Addresses : 1 Last Source Address : 0003.a089.efc5 Security Violation Count : 1