%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#282828', 'primaryTextColor': '#ebdbb2', 'primaryBorderColor': '#d79921', 'lineColor': '#83a598', 'secondaryColor': '#3c3836', 'tertiaryColor': '#504945', 'background': '#1d2021', 'mainBkg': '#282828', 'nodeBorder': '#d79921', 'clusterBkg': '#3c3836', 'titleColor': '#ebdbb2', 'edgeLabelBackground': '#3c3836'}}}%% flowchart TD subgraph ERA1["🕐 ยุคที่ 1: Leased Line (1970s-1990s)"] A["ARPANET - 1969"]:::gy --> B["Leased Lines - 1970s"]:::go B --> C["Frame Relay / ATM - 1980s-1990s"]:::go end subgraph ERA2["🕑 ยุคที่ 2: โปรโตคอล VPN แรก (1993-2000)"] D["PPTP - Microsoft - 1993"]:::gb --> E["L2TP - RFC 2661 - 1999"]:::gb E --> F["IPSec - RFC 2401 - 1998"]:::gb end subgraph ERA3["🕒 ยุคที่ 3: SSL/TLS VPN (2001-2010)"] G["OpenVPN - 2001"]:::gg --> H["SSL VPN Appliances - 2004"]:::gg H --> I["Cloud VPN - 2010"]:::gg end subgraph ERA4["🕓 ยุคที่ 4: VPN สมัยใหม่ (2015-ปัจจุบัน)"] J["WireGuard - Linux Kernel - 2015"]:::ga --> K["Zero-Trust VPN - 2018"]:::ga K --> L["Mesh VPN - Tailscale - 2020+"]:::ga end ERA1 --> ERA2 --> ERA3 --> ERA4 classDef gy fill:#282828,stroke:#d79921,color:#ebdbb2 classDef go fill:#282828,stroke:#d65d0e,color:#ebdbb2 classDef gb fill:#282828,stroke:#458588,color:#ebdbb2 classDef gg fill:#282828,stroke:#98971a,color:#ebdbb2 classDef ga fill:#282828,stroke:#689d6a,color:#ebdbb2
%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#282828', 'primaryTextColor': '#ebdbb2', 'primaryBorderColor': '#d79921', 'lineColor': '#83a598', 'secondaryColor': '#3c3836'}}}%% flowchart LR subgraph SITE_A["🏢 สำนักงานกรุงเทพ - 192.168.1.0/24"] PC_A1["💻 PC-A1"]:::gg GW_A["🔒 VPN Gateway - 203.0.113.1"]:::gy PC_A1 --> GW_A end subgraph INTERNET["🌐 Internet"] NET["--- Encrypted Tunnel ---"]:::go end subgraph SITE_B["🏢 สำนักงานเชียงใหม่ - 10.0.0.0/24"] GW_B["🔒 VPN Gateway - 198.51.100.1"]:::gy SRV_B1["🖥️ Server-B1"]:::gb GW_B --> SRV_B1 end GW_A <--> |"🔐 Encrypted"| NET NET <--> |"🔐 Encrypted"| GW_B classDef gy fill:#282828,stroke:#d79921,color:#ebdbb2 classDef go fill:#504945,stroke:#d65d0e,color:#fe8019 classDef gb fill:#282828,stroke:#458588,color:#ebdbb2 classDef gg fill:#282828,stroke:#98971a,color:#ebdbb2
%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#282828', 'primaryTextColor': '#ebdbb2', 'primaryBorderColor': '#d79921', 'lineColor': '#83a598', 'secondaryColor': '#3c3836'}}}%% flowchart TD subgraph USERS["👥 ผู้ใช้ระยะไกล"] U1["🏠 Work From Home"]:::gg U2["☕ Cafe / โรงแรม"]:::gg U3["📱 มือถือ 4G/5G"]:::gg end VS["🔒 VPN Concentrator - 203.0.113.1:51820"]:::gy subgraph CORP["🏢 เครือข่ายองค์กร - 172.16.0.0/16"] DB["🗄️ Database Server"]:::gb FILE["📁 File Server"]:::gb INTRA["🌐 Intranet"]:::ga end U1 -->|"🔐 Encrypted Tunnel"| VS U2 -->|"🔐 Encrypted Tunnel"| VS U3 -->|"🔐 Encrypted Tunnel"| VS VS --> DB VS --> FILE VS --> INTRA classDef gy fill:#282828,stroke:#d79921,color:#ebdbb2 classDef gb fill:#282828,stroke:#458588,color:#ebdbb2 classDef gg fill:#282828,stroke:#98971a,color:#ebdbb2 classDef ga fill:#282828,stroke:#689d6a,color:#ebdbb2
%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#282828', 'primaryTextColor': '#ebdbb2', 'primaryBorderColor': '#d79921', 'lineColor': '#83a598', 'secondaryColor': '#3c3836'}}}%% flowchart LR subgraph ORIGINAL["📦 แพ็กเก็ตต้นฉบับ"] O1["IP Header - Src: 192.168.1.10"]:::gb O2["TCP Header - Port 443"]:::gg O3["Data (Payload)"]:::ga end subgraph ENCRYPTED["🔒 เข้ารหัส Payload"] E1["IP Header (เดิม)"]:::gb E2["TCP Header (เดิม)"]:::gg E3["🔐 Encrypted Data"]:::go end subgraph TUNNEL["🌐 ห่อหุ้มด้วย Tunnel Header"] T1["Outer IP Header - Src: 203.0.113.1"]:::gy T2["VPN Header (WireGuard/IPSec)"]:::go T3["🔒 Inner Encrypted Packet"]:::gr end ORIGINAL -->|"1️⃣ Encrypt"| ENCRYPTED ENCRYPTED -->|"2️⃣ Encapsulate"| TUNNEL classDef gy fill:#282828,stroke:#d79921,color:#ebdbb2 classDef go fill:#282828,stroke:#d65d0e,color:#ebdbb2 classDef gb fill:#282828,stroke:#458588,color:#ebdbb2 classDef gg fill:#282828,stroke:#98971a,color:#ebdbb2 classDef ga fill:#282828,stroke:#689d6a,color:#ebdbb2 classDef gr fill:#282828,stroke:#cc241d,color:#ebdbb2
%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#282828', 'primaryTextColor': '#ebdbb2', 'primaryBorderColor': '#d79921', 'lineColor': '#83a598', 'secondaryColor': '#3c3836'}}}%% flowchart TD IPSEC["🛡️ IPSec Suite"]:::gy subgraph PROTOCOLS["โปรโตคอลหลัก"] AH["AH - Authentication Header - IP Protocol 51 — Authentication เท่านั้น"]:::gb ESP["ESP - Encapsulating Security Payload - IP Protocol 50 — Auth + Encryption ✅"]:::gg end subgraph MODES["โหมดการทำงาน"] TRANSPORT["Transport Mode — Host-to-Host"]:::go TUNNEL["Tunnel Mode — Gateway-to-Gateway"]:::go end subgraph IKE["IKE - Internet Key Exchange"] IKEv1["IKEv1 — เก่า ซับซ้อน"]:::gr IKEv2["IKEv2 (แนะนำ) — เร็ว รองรับ MOBIKE"]:::ga end IPSEC --> AH IPSEC --> ESP IPSEC --> TRANSPORT IPSEC --> TUNNEL IPSEC --> IKEv1 IPSEC --> IKEv2 classDef gy fill:#282828,stroke:#d79921,color:#ebdbb2 classDef gb fill:#282828,stroke:#458588,color:#ebdbb2 classDef gg fill:#282828,stroke:#98971a,color:#ebdbb2 classDef go fill:#282828,stroke:#d65d0e,color:#ebdbb2 classDef ga fill:#282828,stroke:#689d6a,color:#ebdbb2 classDef gr fill:#282828,stroke:#cc241d,color:#ebdbb2
%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#282828', 'primaryTextColor': '#ebdbb2', 'primaryBorderColor': '#d79921', 'lineColor': '#83a598', 'secondaryColor': '#3c3836'}}}%% sequenceDiagram participant C as 💻 Client participant S as 🔒 VPN Server C->>S: ClientHello (TLS Version, Cipher Suites, Random_C) S->>C: ServerHello (เลือก Cipher Suite, Random_S) S->>C: Certificate (X.509 Public Key) S->>C: ServerHelloDone C->>C: ✅ ตรวจสอบ Certificate C->>S: ClientKeyExchange (Encrypted Pre-Master Secret) C->>S: ChangeCipherSpec + Finished S->>C: ChangeCipherSpec + Finished Note over C,S: 🔐 Session Established C->>S: VPN Data (Encrypted)
%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#282828', 'primaryTextColor': '#ebdbb2', 'primaryBorderColor': '#d79921', 'lineColor': '#83a598', 'secondaryColor': '#3c3836'}}}%% flowchart LR subgraph WG_CRYPTO["🔐 Cryptographic Primitives"] C1["Curve25519 - Key Exchange (ECDH)"]:::gy C2["ChaCha20-Poly1305 - Authenticated Encryption"]:::gg C3["BLAKE2s - Hashing"]:::gb C4["SipHash24 - Hashtable Keys"]:::ga C5["HKDF - Key Derivation"]:::go end subgraph WG_SESSION["📡 Session Management"] S1["Noise Protocol - Handshake"]:::gp S2["Static Keys - Long-term Identity"]:::gy S3["Ephemeral Keys - Per-session"]:::gg S4["Session Keys - สำหรับ Data"]:::gb end C1 --> S1 C2 --> S4 C3 --> S1 S1 --> S2 S1 --> S3 S3 --> S4 classDef gy fill:#282828,stroke:#d79921,color:#ebdbb2 classDef gb fill:#282828,stroke:#458588,color:#ebdbb2 classDef gg fill:#282828,stroke:#98971a,color:#ebdbb2 classDef go fill:#282828,stroke:#d65d0e,color:#ebdbb2 classDef ga fill:#282828,stroke:#689d6a,color:#ebdbb2 classDef gp fill:#282828,stroke:#b16286,color:#ebdbb2
%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#282828', 'primaryTextColor': '#ebdbb2', 'primaryBorderColor': '#d79921', 'lineColor': '#83a598', 'secondaryColor': '#3c3836'}}}%% flowchart TD subgraph CLIENT["💻 Client"] APP["🌐 Application"]:::gb IPTBL["iptables Rules - (สร้างโดย sshuttle)"]:::gy SSHUTTLE["sshuttle Process - (Local Proxy)"]:::gg end subgraph TUNNEL["🔐 SSH Tunnel"] T["SSH Encrypted Channel - Port 22"]:::go end subgraph SERVER["🖥️ SSH Server"] SSH_SRV["SSH Daemon"]:::ga PY["Python Helper - (auto-uploaded)"]:::gg FWD["Forward to Destination"]:::gb end DEST["🌍 Web Server - 10.0.0.20:80"]:::gr APP -->|"1️⃣ TCP"| IPTBL IPTBL -->|"2️⃣ Redirect"| SSHUTTLE SSHUTTLE -->|"3️⃣ SSH"| T T --> SSH_SRV --> PY -->|"4️⃣ Forward"| FWD --> DEST classDef gy fill:#282828,stroke:#d79921,color:#ebdbb2 classDef go fill:#282828,stroke:#d65d0e,color:#ebdbb2 classDef gb fill:#282828,stroke:#458588,color:#ebdbb2 classDef gg fill:#282828,stroke:#98971a,color:#ebdbb2 classDef ga fill:#282828,stroke:#689d6a,color:#ebdbb2 classDef gr fill:#282828,stroke:#cc241d,color:#ebdbb2
%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#282828', 'primaryTextColor': '#ebdbb2', 'primaryBorderColor': '#d79921', 'lineColor': '#83a598', 'secondaryColor': '#3c3836'}}}%% mindmap root(("🔒 VPN Security - Best Practices")) ("🔑 Key Management") ["RSA ≥ 2048 / EC ≥ 256"] ["หมุนเวียน Key สม่ำเสมอ"] ["เก็บ Private Key อย่างปลอดภัย"] ("🔐 Encryption") ["ChaCha20 / AES-256-GCM"] ["หลีกเลี่ยง DES, 3DES, RC4"] ["Perfect Forward Secrecy (PFS)"] ("🛡️ Authentication") ["Multi-Factor Auth (MFA)"] ["Certificate-based Auth"] ("📡 Network & Operations") ["จำกัด Access ด้วย Firewall"] ["Monitor VPN Logs สม่ำเสมอ"] ["อัปเดต VPN Software สม่ำเสมอ"]
%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#282828', 'primaryTextColor': '#ebdbb2', 'primaryBorderColor': '#d79921', 'lineColor': '#83a598', 'secondaryColor': '#3c3836'}}}%% flowchart TD START["🤔 ต้องการใช้ VPN ประเภทไหน?"]:::gy Q1{"มี SSH Server - ที่เข้าถึงได้?"}:::gb Q2{"ต้องการ - ประสิทธิภาพสูง?"}:::gb Q3{"มี Root Access - บน Server?"}:::gb Q4{"ต้องผ่าน - Firewall เข้มงวด?"}:::gb Q5{"ต้องการ - Enterprise Features?"}:::gb SSHUTTLE["✅ Sshuttle - VPN over SSH"]:::gg WIREGUARD["✅ WireGuard - เร็วที่สุด ทันสมัย"]:::gg OPENVPN_TCP["✅ OpenVPN (TCP 443) - ผ่าน Firewall ได้"]:::ga IPSEC["✅ IPSec IKEv2 - Enterprise Standard"]:::go OPENVPN["✅ OpenVPN - ยืดหยุ่น ทุก Platform"]:::ga START --> Q1 Q1 -->|"ใช่"| SSHUTTLE Q1 -->|"ไม่ใช่"| Q3 Q3 -->|"ไม่มี Root"| Q4 Q3 -->|"มี Root"| Q2 Q2 -->|"ใช่"| WIREGUARD Q2 -->|"ปานกลาง"| Q5 Q4 -->|"เข้มงวดมาก"| OPENVPN_TCP Q4 -->|"ปกติ"| WIREGUARD Q5 -->|"ใช่"| IPSEC Q5 -->|"ไม่"| OPENVPN classDef gy fill:#282828,stroke:#d79921,color:#ebdbb2 classDef gb fill:#282828,stroke:#458588,color:#ebdbb2 classDef gg fill:#282828,stroke:#98971a,color:#ebdbb2 classDef go fill:#282828,stroke:#d65d0e,color:#ebdbb2 classDef ga fill:#282828,stroke:#689d6a,color:#ebdbb2
%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#282828', 'primaryTextColor': '#ebdbb2', 'primaryBorderColor': '#d79921', 'lineColor': '#83a598', 'secondaryColor': '#3c3836'}}}%% flowchart TD subgraph CONCEPTS["📚 แนวคิดหลัก"] C1["🌐 VPN คืออะไร? - Tunnel เสมือนบน Internet"]:::gy C2["📡 ประเภท VPN - Site-to-Site / Remote Access"]:::gy C3["🔐 Tunneling - Encapsulation + MTU"]:::gy end subgraph PROTOCOLS_LEARNED["🛡️ Protocols ที่ศึกษา"] P1["IPSec IKEv2 + ESP - Enterprise Standard"]:::gb P2["SSL/TLS VPN - Port 443 Clientless"]:::gb P3["WireGuard - ทันสมัย เร็ว Kernel-level"]:::gg end subgraph TOOLS_USED["🔧 เครื่องมือที่ใช้"] T1["wg / wg-quick - จัดการ WireGuard"]:::go T2["sshuttle - VPN over SSH"]:::go end subgraph SECURITY["🔒 Security"] S1["Perfect Forward Secrecy"]:::ga S2["ChaCha20 / AES-256-GCM"]:::ga S3["MFA + Monitoring"]:::ga end CONCEPTS --> PROTOCOLS_LEARNED PROTOCOLS_LEARNED --> TOOLS_USED TOOLS_USED --> SECURITY classDef gy fill:#282828,stroke:#d79921,color:#ebdbb2 classDef gb fill:#282828,stroke:#458588,color:#ebdbb2 classDef gg fill:#282828,stroke:#98971a,color:#ebdbb2 classDef go fill:#282828,stroke:#d65d0e,color:#ebdbb2 classDef ga fill:#282828,stroke:#689d6a,color:#ebdbb2