ทำไมถึงสร้าง Firewall/Router เอง (DIY Network Security Appliance)?
- คุ้มค่า: Hardware ราคาถูกกว่า Enterprise Appliance มาก (ไม่มี License Fee ต่อปี)
- ยืดหยุ่น: ติดตั้ง Package/Service อะไรก็ได้ (IDS/IPS, VPN, Proxy, DNS Filter, DHCP, RADIUS, Monitoring)
- ความโปร่งใส: Open Source (pfSense/OPNsense) โค้ดเปิด ตรวจสอบได้ ไม่มี Backdoor
- การเรียนรู้: เข้าใจ Network Security ในระดับลึก
- ประสิทธิภาพ: สเปก Hardware ควบคุมได้ ใช้ CPU แรง, RAM มาก, NIC หลายพอร์ต, AES-NI, QuickAssist
เลือกซอฟต์แวร์: pfSense vs OPNsense
| ด้านเปรียบเทียบ | pfSense (Netgate) | OPNsense (Deciso) |
| Base OS | FreeBSD | FreeBSD (HardenedBSD) |
| License | Apache 2.0 (CE), Proprietary (Plus/Factory) | BSD License (Fully Open Source) |
| Release Cycle | ช้า (Major ทุก 2-3 ปี) | เร็ว (Major ทุก 6 เดือน, Minor ทุก 2 สัปดาห์) |
| UI/UX | ดั้งเดิม ค่อนข้าง Complex | สมัยใหม่ Bootstrap, Responsive, Wizard ดี |
| Plugins/Packages | เยอะ มature (Suricata, Snort, pfBlockerNG, ntopng, Zabbix, Telegraf) | น้อยกว่าเล็กน้อย แต่ Core Features รวมอยู่แล้ว (OSPF, BGP, VXLAN, WireGuard, CrowdSec, Zenarmor/Sunny Valley) |
| Hardware Support | Netgate Hardware (SG-1100, 2100, 3100, 4100, 5100, 6100, 8200) | Generic x86_64, ARM (Raspberry Pi 4, Protectli, Qotom, Mini PC), Netgate Hardware ก็รันได้ |
| Community/Support | ใหญ่กว่า, Forum, Reddit, Docs, Paid Support (Netgate TAC) | เติบโตเร็ว, Forum, Discord, Docs, Paid Support (Deciso/Partners) |
| แนะนำสำหรับ | Enterprise, ความเสถียรสูง, Netgate Hardware, Legacy pfSense Users | Home Lab, SMB, Modern UI, Frequent Updates, Open Source Purist, Non-x86 Hardware |
สเปกฮาร์ดแวร์ขั้นต่ำและแนะนำ (Minimum / Recommended)
| Component | Minimum (Home/Small Office) | Recommended (SMB/Prosumer) | High Performance (Enterprise/1Gbps+) |
| CPU | Dual-core x86_64 (Intel Celeron J4125, N5105, i3-8100T) | Quad-core (Intel i5-8500T, i3-12100, N100, N200) | 6-8+ cores (Intel i5-13500, i7-12700, Xeon D/E, AMD Ryzen 5700G/7700) |
| RAM | 4 GB DDR4 | 8-16 GB DDR4/DDR5 | 16-32+ GB DDR5 ECC |
| Storage | 32 GB SSD (SATA/mSATA/M.2) | 128-256 GB NVMe SSD | 256-512+ GB NVMe (Mirror/ZFS) |
| NIC (Ethernet Ports) | 2x Intel i210/i211/i225/i226 (2.5GbE) | 4x Intel i226 (2.5GbE) or i350 (1GbE) + SFP+ | 4-8x 10GbE/25GbE (Intel X550, X710, E810, Mellanox ConnectX) |
| Form Factor | Mini PC, Thin Client, SFF (Dell Wyse, HP t630/t640, Lenovo Tiny) | 1U Rackmount, Mini PC 4-port (Protectli, Qotom, Kingnovy, Jetway) | 1U/2U Rackmount Server (Supermicro, Dell R240/R340, Custom) |
| Power | 15-25W | 25-45W | 60-150W |
| สำคัญ | AES-NI (CPU รองรับ AES Hardware Acceleration) บังคับ สำหรับ VPN/IPsec Performance |
ตัวเลือกฮาร์ดแวร์ยอดนิยม 2024 (Value for Money)
- Budget Mini PC: Beelink/Minisforum/GMKtec N100/N200/N305 (4-8GB RAM, 128-256GB, 2x 2.5GbE) ~$150-250
- Protectli Vault: VP2420 (4-port 2.5GbE, N5105) / VP4670 (6-port, i5-8265U) - รัน pfSense/OPNsense ได้จากโรงงาน
- Qotom / Kingnovy / Jetway: Barebone 4-6 port Intel i226/i211
- Used Thin Client: Dell Wyse 5070/5470 (i5-8500T, 8GB, 128GB, 1x GbE + PCIe Slot สำหรับเพิ่ม NIC) ~$80-120
- Raspberry Pi 4/5 + USB-Ethernet: สำหรับ Lab/เรียนรู้ (ไม่แนะนำ Production 1Gbps+)
- Netgate Appliances: SG-1100 (ARM), 2100, 3100, 4100, 5100, 6100, 8200 (Support pfSense Plus, TAC)
ขั้นตอนการติดตั้ง (Installation Steps)
- ดาวน์โหลด ISO: pfSense CE หรือ OPNsense
- สร้าง Bootable USB: Rufus (Windows) /
dd (Linux/macOS) → เลือк GPT/UEFI (สมัยใหม่) หรือ MBR/BIOS (เก่า)
- Boot จาก USB → ติดตาม Wizard: Accept License, Select Drive, Partition Scheme (Auto ZFS/UFZ), Set Root/Admin Password
- Reboot → Console Menu: Assign Interfaces (WAN, LAN, OPT1...), Set LAN IP (Default 192.168.1.1/24), Enable DHCP Server on LAN
- เข้าถึง Web GUI:
https://192.168.1.1 (Default: admin / pfsense หรือ root / opnsense)
- Wizard: General Setup (Hostname, DNS, NTP), WAN Type (DHCP, PPPoE, Static), LAN DHCP, Timezone
การตั้งค่าพื้นฐานหลังติดตั้ง (Essential Post-Install)
- Firewall Rules: LAN → Any (Default Allow), WAN → Block All (Default Deny), สร้าง Rule Allow เฉพาะที่จำเป็น (Port Forward, VPN)
- DNS: Unbound DNS Resolver (DoT/DoH) + pfBlockerNG-devel / AdGuard Home / Pi-hole สำหรับ Ad/Tracking/Malware Blocking
- VPN: WireGuard (Modern, Fast, Simple) หรือ OpenVPN (Legacy Compatibility) → Export Config/QR Code ให้ Client
- IDS/IPS: Suricata (Inline Mode / Legacy Blocking) + ET Pro Rules / Snort VRT Rules (ต้อง Oinkcode) → Tuning False Positives
- Traffic Shaping / QoS: Limiters, FQ_CoDel, HFSC สำหรับ Bufferbloat Control
- Monitoring: Telegraf + InfluxDB + Grafana / Zabbix / Prometheus + Node Exporter / Netdata
- Backup/Restore: Auto Config Backup (Local + Remote/Nextcloud/S3/Git)
- Updates: System → Update → Check/Install (OPNsense: หน้าหลักมี Notification, pfSense: ต้องเช็คเอง)
แพ็กเกจ/ฟีเจอร์เสริมที่นิยม (Popular Packages)
| Package | ฟังก์ชัน | Platform |
| pfBlockerNG-devel | GeoIP Blocking, DNSBL (Ad/Tracker/Malware), IPv4/IPv6 Lists, TLD, ASN | pfSense |
| Zenarmor (Sunny Valley) | Application Control, Web Filtering, TLS Inspection, Threat Intelligence, Reporting | OPNsense (Native), pfSense (Plugin) |
| CrowdSec | Collaborative IPS, Log Parsing, Decision Engine, Bouncer (Firewall Block) | Both |
| WireGuard | Modern VPN (Kernel Module, Fast, Simple Config) | Both (Built-in OPNsense 23.7+, pfSense 2.7.2+) |
| Tailscale | Mesh VPN over WireGuard (Easy NAT Traversal, ACL) | Both (Package/Container) |
| ntopng | Network Traffic Analysis, Flow Collection, Alerts, Timeseries | Both |
| Zabbix Agent / Telegraf | Infrastructure Monitoring (CPU, RAM, Disk, Interfaces, Services) | Both |
| ACME (Let's Encrypt) | Auto SSL Certificates สำหรับ Web GUI และ Services | Both |
| HAProxy | Load Balancer, Reverse Proxy, SSL Termination, ACME Integration | Both |
| FRR (Free Range Routing) | Dynamic Routing: OSPF, BGP, RIP, BFD, VRF | Both |
ค่าใช้จ่ายโดยประมาณ (Cost Estimate 2024)
| ระดับ | Hardware | Software | Power/Year | Total Year 1 |
| Home Lab | $100-200 (Used Thin Client / Pi + USB-NIC) | Free (Open Source) | $15-30 | $115-230 |
| SMB / Prosumer | $250-500 (Protectli, Mini PC 4-port 2.5GbE) | Free / OPNsense Business €500/yr (Support) | $30-60 | $280-1060 |
| Enterprise | $1000-5000+ (1U Server, Multi-10GbE, ECC RAM, Redundant PSU) | pfSense Plus (Netgate TAC) $~2000-5000/yr หรือ OPNsense Business | $100-500 | $3100-10500+ |
ข้อควรระวังและ Best Practices
- Physical Security: วางใน Rack/Locked Cabinet, UPS, Environmental Monitoring
- Management Access: ให้เข้าถึง Web GUI/SSH ได้เฉพาะ Management VLAN/VPN เท่านั้น (Anti-Lockout Rule ระวัง!)
- Certificate Management: ใช้ ACME (Let's Encrypt) ใส่ Cert จริงสำหรับ Web GUI, VPN, Proxy
- High Availability (CARP/pfsync): ต้องมี Hardware คู่เดียวกัน, Dedicated Sync Interface, Shared State
- Documentation: เก็บ Config, Network Diagram, Change Log, Runbook ใน Git/Wiki
- Testing: Lab First → Staging → Production, Change Management Process
สรุป
สร้าง Network Security Appliance เองด้วย pfSense หรือ OPNsense เป็นทางเลือกที่ยอดเยี่ยมสำหรับ Home Lab, SMB และ Enterprise ที่ต้องการความยืดหยุ่น ความโปร่งใส และค่าใช้จ่ายต่ำกว่า Vendor Appliance จุดสำคัญ: CPU รองรับ AES-NI, Intel NICs, RAM/Storage เพียงพอ, การออกแบบ Network Segmentation ที่ดี, และกระบวนการ Backup/Update/Monitoring ที่เข้มงวด