Chuyển đến nội dung chính

Bài 7: VLANs, Bonding và Bridge

Cấu hình VLANs, Bonding và Bridge trên VyOS, thực hành phân đoạn mạng, lab và tổng kết kiến thức.

VLANs, Bonding và Bridge

Giới thiệu về VLANs, Bonding và Bridge trên VyOS

Bài học này hướng dẫn cấu hình VLANs (802.1Q), Bonding (gộp nhiều interface vật lý) và Bridge (cầu nối mạng) trên VyOS 1.4.x/1.5 rolling release. Đây là các kỹ thuật quan trọng để phân đoạn, tối ưu và mở rộng mạng LAN.

1. Cấu hình VLANs (802.1Q)

VLAN giúp phân chia mạng vật lý thành nhiều mạng logic, tăng bảo mật và hiệu quả quản lý.

set interfaces ethernet eth0 vif 10 address 192.168.10.1/24
set interfaces ethernet eth0 vif 20 address 192.168.20.1/24
  • Router-on-a-stick (Inter-VLAN Routing):
set interfaces ethernet eth0 vif 30 address 192.168.30.1/24

Trên switch, cấu hình trunk port cho eth0, access port cho các VLAN.

2. Cấu hình Bonding (Gộp nhiều interface)

Bonding giúp tăng băng thông và dự phòng bằng cách gộp nhiều interface vật lý.

set interfaces bonding bond0 mode 802.3ad
set interfaces bonding bond0 member interface eth1
set interfaces bonding bond0 member interface eth2
set interfaces bonding bond0 address 10.10.10.1/24

Chế độ 802.3ad (LACP) yêu cầu switch hỗ trợ LACP.

3. Cấu hình Bridge Interface

Bridge giúp kết nối nhiều interface vật lý hoặc VLAN thành một mạng logic.

set interfaces bridge br0 member interface eth3
set interfaces bridge br0 member interface eth4
set interfaces bridge br0 address 192.168.50.1/24

4. Kết hợp VLANs với Bridge và Firewall Zones

Có thể kết hợp bridge với các VLAN để phân vùng mạng, ví dụ:

set interfaces bridge br1 member interface eth0.10
set interfaces bridge br1 member interface eth5
set interfaces bridge br1 address 192.168.60.1/24

Kết hợp với firewall zone để kiểm soát truy cập giữa các phân đoạn.

5. Thực hành: Phân đoạn LAN/GUEST/IoT

+-------------------+
|   VyOS Router     |
|                   |
|  eth0 (trunk)     |
+--------+----------+
         |
   +-----+-----+
   |   Switch  |
   +-----+-----+
         |
   +-----+-----+
   |   PC LAN  | (VLAN 10)
   +-----------+
   |   PC Guest| (VLAN 20)
   +-----------+
   |   IoT Dev | (VLAN 30)
   +-----------+

6. Lab thực hành: Cấu hình VLAN, Bonding, Bridge

  1. Đăng nhập VyOS, xác định các interface vật lý.
  2. Cấu hình VLANs, bonding, bridge như trên.
  3. Commit và save cấu hình:
commit
save
  1. Cấu hình switch trunk/access phù hợp.
  2. Kiểm tra kết nối giữa các VLAN, bridge.
show interfaces
show bridge br0

7. Tổng kết

Bạn đã biết cách cấu hình VLANs, bonding và bridge trên VyOS, ứng dụng vào phân đoạn mạng, tăng dự phòng và tối ưu hệ thống.