Menu

9/9/25

pfSense 2.6 kết nối trunk với switch Cisco layer 2 cho vlan ra NET

 


1. Mô hình tổng quan

  • pfSense có 1 interface trunk (em0) kết nối với switch Cisco.
  • Switch có 2 VLAN: 10 và 20.
  • Các PC gắn vào switch ở các port access VLAN 10 hoặc 20.
  • pfSense làm gateway và NAT ra Internet.

⚙️ 2. Cấu hình pfSense

🔹 a. Tạo VLANs

Vào Interfaces > Assignments > VLANs:

  • Tạo VLAN 10 trên em0
  • Tạo VLAN 20 trên em0

🔹 b. Gán interface

Vào Interfaces > Assignments:

  • Gán VLAN 10 thành LAN10, bật interface
  • Gán VLAN 20 thành LAN20, bật interface

🔹 c. Gán IP cho VLAN interfaces

  • LAN10: IP 172.16.10.254/24
  • LAN20: IP 172.16.20.254/24

🔹 d. DHCP Server (nếu cần)

Vào Services > DHCP Server:

  • Bật DHCP cho LAN10:
    • Range: 172.16.10.100 - 172.16.10.200
  • Bật DHCP cho LAN20:
    • Range: 172.16.20.100 - 172.16.20.200

🔹 e. NAT cấu hình

Vào Firewall > NAT > Outbound:

  • Chuyển sang chế độ Hybrid
  • Tạo 2 rule:

Rule 1:

  • Interface: WAN
  • Source: 172.16.10.0/24
  • Translation: Interface address
  • Description: NAT VLAN 10

Rule 2:

  • Interface: WAN
  • Source: 172.16.20.0/24
  • Translation: Interface address
  • Description: NAT VLAN 20


🔹 f. Firewall Rules

Vào Firewall > Rules > LAN10:

  • Tạo rule:
    • Action: Pass
    • Protocol: Any
    • Source: LAN10 net
    • Destination: Any

Vào Firewall > Rules > LAN20:

  • Tạo rule tương tự cho LAN20 net



🖧 3. Cấu hình Switch Cisco Layer 2

🔹 a. Tạo VLANs

conf t
vlan 10
vlan 20

🔹 b. Cấu hình trunk port kết nối pfSense

interface GigabitEthernet0/1
switchport trunk encapsulation dot1q
switchport mode trunk
switchport trunk allowed vlan 10,20

🔹 c. Cấu hình access port cho PC
interface GigabitEthernet0/2
switchport mode access
switchport access vlan 10

interface GigabitEthernet0/3
switchport mode access
switchport access vlan 20

💻 4. Cấu hình PC trong VLAN

1. xin DHCP cho tinycore linux:

sudo udhcpc -i eth0; 

2. xem ip gateway: ip route






5. Kiểm tra kết nối

  • Ping từ PC đến gateway (172.16.10.254 hoặc 172.16.20.254)
  • Ping ra Internet (ping 8.8.8.8)
  • Kiểm tra DNS nếu không truy cập được web


No comments:

Post a Comment