%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#282828', 'primaryTextColor': '#ebdbb2', 'primaryBorderColor': '#504945', 'lineColor': '#a89984', 'secondaryColor': '#3c3836', 'tertiaryColor': '#1d2021', 'background': '#282828', 'mainBkg': '#282828', 'nodeBorder': '#504945', 'clusterBkg': '#32302f', 'titleColor': '#fabd2f', 'edgeLabelBackground': '#3c3836', 'fontFamily': 'monospace' }}}%% flowchart TB subgraph era1["ยุคที่ 1: 1980s — Packet Filtering"] A["📦 Static Packet Filter - (กรองแพ็กเก็ตพื้นฐาน)"] end subgraph era2["ยุคที่ 2: 1990s — Stateful"] B["🔄 Stateful Inspection - (ตรวจสอบสถานะการเชื่อมต่อ)"] end subgraph era3["ยุคที่ 3: 2000s — Application Layer"] C["🖥️ Application Firewall - (WAF, Proxy-based)"] end subgraph era4["ยุคที่ 4: 2010s+ — NGFW"] D["🧠 Next-Gen Firewall - (DPI, IPS/IDS, AI)"] end A --> B --> C --> D style era1 fill:#3c3836,stroke:#fabd2f,color:#ebdbb2 style era2 fill:#3c3836,stroke:#b8bb26,color:#ebdbb2 style era3 fill:#3c3836,stroke:#83a598,color:#ebdbb2 style era4 fill:#3c3836,stroke:#d3869b,color:#ebdbb2 style A fill:#1d2021,stroke:#fabd2f,color:#fabd2f style B fill:#1d2021,stroke:#b8bb26,color:#b8bb26 style C fill:#1d2021,stroke:#83a598,color:#83a598 style D fill:#1d2021,stroke:#d3869b,color:#d3869b
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#282828', 'primaryTextColor': '#ebdbb2', 'primaryBorderColor': '#504945', 'lineColor': '#a89984', 'background': '#282828', 'mainBkg': '#282828', 'nodeBorder': '#504945', 'clusterBkg': '#32302f', 'titleColor': '#fabd2f', 'edgeLabelBackground': '#3c3836', 'fontFamily': 'monospace' }}}%% stateDiagram-v2 [*] --> NEW : แพ็กเก็ตแรก (SYN) NEW --> ESTABLISHED : SYN-ACK ได้รับ ESTABLISHED --> RELATED : เปิด connection ใหม่ที่เกี่ยวข้อง ESTABLISHED --> CLOSE_WAIT : FIN ได้รับ RELATED --> ESTABLISHED : ส่งข้อมูลผ่าน CLOSE_WAIT --> [*] : การเชื่อมต่อสิ้นสุด ESTABLISHED --> INVALID : ผิดรูปแบบ INVALID --> [*] : DROP แพ็กเก็ต
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#282828', 'primaryTextColor': '#ebdbb2', 'primaryBorderColor': '#504945', 'lineColor': '#a89984', 'background': '#282828', 'mainBkg': '#282828', 'nodeBorder': '#504945', 'clusterBkg': '#32302f', 'titleColor': '#fabd2f', 'edgeLabelBackground': '#3c3836', 'fontFamily': 'monospace' }}}%% flowchart TB subgraph stateless["🔴 Stateless — ตรวจทุกแพ็กเก็ตแยกกัน"] P1["แพ็กเก็ต A - SYN"] --> R1{"ตรวจ Rules - เฉพาะ Header"} P2["แพ็กเก็ต B - ACK"] --> R2{"ตรวจ Rules - เฉพาะ Header"} R1 -->|"ALLOW/DENY"| OUT1["ผลลัพธ์"] R2 -->|"ALLOW/DENY"| OUT2["ผลลัพธ์"] end subgraph stateful["🟢 Stateful — จำสถานะการเชื่อมต่อ"] P3["แพ็กเก็ต A - SYN"] --> ST["State Table - (ตารางสถานะ)"] ST --> R3{"ตรวจ Rules - + State"} P4["แพ็กเก็ต B - ACK"] --> ST R3 -->|"ALLOW"| OUT3["ผลลัพธ์"] end style stateless fill:#3c3836,stroke:#fb4934,color:#ebdbb2 style stateful fill:#3c3836,stroke:#b8bb26,color:#ebdbb2 style ST fill:#1d2021,stroke:#fabd2f,color:#fabd2f
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#282828', 'primaryTextColor': '#ebdbb2', 'primaryBorderColor': '#504945', 'lineColor': '#a89984', 'background': '#282828', 'mainBkg': '#282828', 'nodeBorder': '#504945', 'clusterBkg': '#32302f', 'titleColor': '#fabd2f', 'edgeLabelBackground': '#3c3836', 'fontFamily': 'monospace' }}}%% flowchart TB INTERNET["🌐 Internet - (Untrusted Zone - Trust = 0)"] subgraph DMZ["🟡 DMZ - (Demilitarized Zone — Trust = 50)"] WEB["🖥️ Web Server"] MAIL["📧 Mail Server"] DNS["🔍 DNS Server"] end subgraph INTERNAL["🟢 Internal Network - (Trusted Zone — Trust = 100)"] PC["💻 User Workstations"] DB["🗄️ Database Server"] AD["🔑 Active Directory"] end subgraph MGMT["🔵 Management Zone - (Restricted — Trust = 75)"] FW_MGMT["⚙️ Firewall Console"] SIEM["📊 SIEM/Log Server"] end INTERNET -->|"HTTP/HTTPS - SMTP"| DMZ DMZ -->|"DB Queries - (Filtered)"| DB style DMZ fill:#3c3836,stroke:#fabd2f,color:#ebdbb2 style INTERNAL fill:#3c3836,stroke:#b8bb26,color:#ebdbb2 style MGMT fill:#3c3836,stroke:#83a598,color:#ebdbb2 style INTERNET fill:#1d2021,stroke:#fb4934,color:#fb4934
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#282828', 'primaryTextColor': '#ebdbb2', 'primaryBorderColor': '#504945', 'lineColor': '#a89984', 'background': '#282828', 'mainBkg': '#282828', 'nodeBorder': '#504945', 'clusterBkg': '#32302f', 'titleColor': '#fabd2f', 'edgeLabelBackground': '#3c3836', 'fontFamily': 'monospace' }}}%% flowchart TB I["🌐 Internet"] FW1["🔥 Firewall ภายนอก - (Outer Firewall)"] FW2["🔥 Firewall ภายใน - (Inner Firewall)"] subgraph DMZ_ZONE["🟡 DMZ"] WEB["Web Server - 192.168.1.10"] SMTP["Mail Server - 192.168.1.20"] end subgraph INT_ZONE["🟢 Internal Network"] APP["App Server - 10.0.0.10"] DB["Database - 10.0.0.20"] CLIENT["Clients - 10.0.0.0/24"] end I --> FW1 --> DMZ_ZONE --> FW2 --> INT_ZONE style DMZ_ZONE fill:#3c3836,stroke:#fabd2f,color:#ebdbb2 style INT_ZONE fill:#3c3836,stroke:#b8bb26,color:#ebdbb2 style FW1 fill:#1d2021,stroke:#fb4934,color:#fb4934 style FW2 fill:#1d2021,stroke:#fb4934,color:#fb4934
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#282828', 'primaryTextColor': '#ebdbb2', 'primaryBorderColor': '#504945', 'lineColor': '#a89984', 'background': '#282828', 'mainBkg': '#282828', 'nodeBorder': '#504945', 'clusterBkg': '#32302f', 'titleColor': '#fabd2f', 'edgeLabelBackground': '#3c3836', 'fontFamily': 'monospace' }}}%% flowchart TB subgraph SW["Physical Switch (สวิตช์จริง 1 ตัว)"] subgraph VLAN10["VLAN 10 — HR - 10.10.10.0/24"] H1["💻 HR-PC1"] H2["💻 HR-PC2"] end subgraph VLAN20["VLAN 20 — Finance - 10.20.20.0/24"] F1["💻 Finance-PC1"] F2["🖨️ Finance-Printer"] end subgraph VLAN30["VLAN 30 — IT - 10.30.30.0/24"] I1["🖥️ Server1"] I2["🖥️ Server2"] end end ROUTER["🔀 Layer 3 Router/Switch - (Inter-VLAN Routing)"] VLAN10 <-->|"Trunk Port - 802.1Q"| ROUTER VLAN20 <-->|"Trunk Port - 802.1Q"| ROUTER VLAN30 <-->|"Trunk Port - 802.1Q"| ROUTER style VLAN10 fill:#3c3836,stroke:#83a598,color:#ebdbb2 style VLAN20 fill:#3c3836,stroke:#fabd2f,color:#ebdbb2 style VLAN30 fill:#3c3836,stroke:#d3869b,color:#ebdbb2 style SW fill:#1d2021,stroke:#504945,color:#a89984 style ROUTER fill:#1d2021,stroke:#b8bb26,color:#b8bb26
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#282828', 'primaryTextColor': '#ebdbb2', 'primaryBorderColor': '#504945', 'lineColor': '#a89984', 'background': '#282828', 'mainBkg': '#282828', 'nodeBorder': '#504945', 'clusterBkg': '#32302f', 'titleColor': '#fabd2f', 'edgeLabelBackground': '#3c3836', 'fontFamily': 'monospace' }}}%% flowchart TB USER["👤 ผู้ใช้งาน - (Admin)"] UFW["🛡️ UFW - (/usr/sbin/ufw)"] subgraph RULES["UFW Rule Files"] URULES["/etc/ufw/user.rules"] USER6["/etc/ufw/user6.rules"] BEFORE["/etc/ufw/before.rules"] AFTER["/etc/ufw/after.rules"] end IPTABLES["⚙️ iptables / ip6tables - (Kernel Netfilter)"] KERNEL["🐧 Linux Kernel - Netfilter Framework"] USER -->|"คำสั่ง ufw"| UFW UFW -->|"แปลงเป็น rules"| RULES RULES -->|"โหลด rules"| IPTABLES IPTABLES -->|"จัดการ packet"| KERNEL style UFW fill:#1d2021,stroke:#fabd2f,color:#fabd2f style RULES fill:#3c3836,stroke:#83a598,color:#ebdbb2 style IPTABLES fill:#1d2021,stroke:#b8bb26,color:#b8bb26 style KERNEL fill:#1d2021,stroke:#d3869b,color:#d3869b
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#282828', 'primaryTextColor': '#ebdbb2', 'primaryBorderColor': '#504945', 'lineColor': '#a89984', 'background': '#282828', 'mainBkg': '#282828', 'nodeBorder': '#504945', 'clusterBkg': '#32302f', 'titleColor': '#fabd2f', 'edgeLabelBackground': '#3c3836', 'fontFamily': 'monospace' }}}%% flowchart LR PKT_IN["📦 Packet ขาเข้า"] LOCAL["🖥️ Local Process"] PKT_OUT["📤 Packet ขาออก"] subgraph FILTER["Table: filter ⭐"] INPUT_F["INPUT"] FORWARD_F["FORWARD"] OUTPUT_F["OUTPUT"] end subgraph NAT_T["Table: nat"] PREROUTE_N["PREROUTING (DNAT)"] POSTROUTE_N["POSTROUTING (SNAT)"] end PKT_IN --> PREROUTE_N PREROUTE_N -->|"Local"| INPUT_F --> LOCAL PREROUTE_N -->|"Forward"| FORWARD_F --> POSTROUTE_N --> PKT_OUT LOCAL --> OUTPUT_F --> POSTROUTE_N style FILTER fill:#3c3836,stroke:#fabd2f,color:#ebdbb2 style NAT_T fill:#3c3836,stroke:#83a598,color:#ebdbb2
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#282828', 'primaryTextColor': '#ebdbb2', 'primaryBorderColor': '#504945', 'lineColor': '#a89984', 'background': '#282828', 'mainBkg': '#282828', 'nodeBorder': '#504945', 'clusterBkg': '#32302f', 'titleColor': '#fabd2f', 'edgeLabelBackground': '#3c3836', 'fontFamily': 'monospace' }}}%% flowchart TB INET["🌐 Simulated Internet - 172.16.0.0/24"] subgraph GW["🔥 Linux Gateway (Ubuntu 22.04 — 3 NICs)"] ETH0["eth0: 172.16.0.1 (WAN)"] ETH1["eth1: 192.168.1.1 (DMZ)"] ETH2["eth2: 10.0.0.1 (LAN)"] end subgraph DMZ_LAB["🟡 DMZ Network - 192.168.1.0/24"] WEB_LAB["🖥️ Web Server - 192.168.1.10"] FTP_LAB["📁 FTP Server - 192.168.1.20"] end subgraph LAN_LAB["🟢 Internal LAN - 10.0.0.0/24"] PC_LAB["💻 Client PC - 10.0.0.100"] DB_LAB["🗄️ DB Server - 10.0.0.200"] end INET --> ETH0 ETH1 --- DMZ_LAB ETH2 --- LAN_LAB style DMZ_LAB fill:#3c3836,stroke:#fabd2f,color:#ebdbb2 style LAN_LAB fill:#3c3836,stroke:#b8bb26,color:#ebdbb2 style GW fill:#1d2021,stroke:#fb4934,color:#fb4934