Module 3 — Networking 1
🧠 ภาพจำก่อนอ่าน: 🌐 Client → 🛣️ Network → 🛡️ Rules → 🖥️ Backend
🎨 Visual Guide ของวิชานี้ — ภาพช่วยจำ ไม่แทนคำอธิบายและคำสั่งจริง
🧭 Visual architecture
หัวข้อที่มีชื่อว่า “🧭 Visual architecture”flowchart TB
Internet((Internet)) --> IGW[Internet Gateway]
IGW --> RT[Public Route Table]
RT --> PUB[Public Subnet]
PUB --> NAT[NAT Gateway]
NAT --> PRT[Private Route Table]
PRT --> PRI[Private Subnet]
PUB --> NACL1[NACL]
PRI --> NACL2[NACL]
PUB --> SG1[Security Group]
PRI --> SG2[Security Group]
ภาพ Diagram
หัวข้อที่มีชื่อว่า “ภาพ Diagram”Diagram นี้เป็นภาพสรุปเพื่อช่วยทำความเข้าใจโครงสร้างของบท/แล็บ โดยยึดแนวคิดจากคู่มือต้นฉบับ Mobile reader copy combined from Part 1 + Part 2. Full source screenshots remain in Google Drive master.
Architecting on AWS 7.12.4 - Module 3: Networking 1 (Part 1)
หัวข้อที่มีชื่อว่า “Architecting on AWS 7.12.4 - Module 3: Networking 1 (Part 1)”Source: Architecting on AWS 7.12.4 (EN) - Student Guide
Covered pages: 114-137
Focus: IP addressing, CIDR, Amazon VPC fundamentals, subnets, internet gateway, route tables, NAT gateway, elastic network interfaces, Elastic IP addresses, Multi-AZ VPC design, network ACLs, and security groups
เป้าหมายของ Module 3 ช่วงนี้
หัวข้อที่มีชื่อว่า “เป้าหมายของ Module 3 ช่วงนี้”Module 3 เริ่มจากโจทย์ของ network engineer 3 เรื่องหลัก:
- จะวาง IP address ให้เพียงพอกับ workload ได้อย่างไร?
- จะสร้าง network infrastructure บน AWS ให้ dynamic และ secure ได้อย่างไร?
- จะ filter inbound/outbound traffic เพื่อป้องกัน resources ได้อย่างไร?
Part 1 นี้ครอบคลุมตั้งแต่พื้นฐาน IP จนถึง security controls สองตัวสำคัญคือ Network ACL และ Security Group
1. Mental Model ก่อนเริ่ม
หัวข้อที่มีชื่อว่า “1. Mental Model ก่อนเริ่ม”ถ้าเธอเคยทำ network on-prem มาก่อน ให้มอง VPC ประมาณนี้:
flowchart TB
VPC[VPC = Network boundary ใน AWS Region]
VPC --> SUBNET[Subnets = แบ่งช่วง IP ภายใน VPC]
SUBNET --> ROUTE[Route Table = ตัดสินใจว่าจะส่ง traffic ไปไหน]
ROUTE --> IGW[Internet Gateway = เชื่อม VPC กับ Internet]
ROUTE --> NAT[NAT Gateway = ให้ private subnet ออก Internet แบบ outbound]
SUBNET --> NACL[Network ACL = Firewall ระดับ Subnet]
SUBNET --> ENI[Elastic Network Interface]
ENI --> SG[Security Group = Firewall ระดับ ENI / Instance]
นี่คือภาพรวมของบทนี้ทั้งหมด
2. IP Address คืออะไร?
หัวข้อที่มีชื่อว่า “2. IP Address คืออะไร?”Student Guide หน้า 119 อธิบายว่า IP address ใช้ระบุตำแหน่งของ resource ภายใน network
ตัวอย่าง IPv4:
172.31.2.15IPv4 address มี 4 octets แต่ละ octet มีค่าตั้งแต่ 0-255
ตัวอย่าง:
172 . 31 . 2 . 15 | | | | +----+----+----+----> แต่ละส่วน = 1 octetIP address มีส่วนที่ใช้ identify network และส่วนที่ใช้ identify host
3. IPv4 vs IPv6
หัวข้อที่มีชื่อว่า “3. IPv4 vs IPv6”Student Guide กล่าวถึง IP address สองประเภทหลัก:
- ใช้ 32-bit address
- เขียนเป็น decimal notation 4 ชุด
- เป็นรูปแบบที่ใช้กันแพร่หลายมาก
ตัวอย่าง:
172.31.2.15- ใช้ 128-bit address
- ถูกออกแบบมาเพื่อแก้ข้อจำกัดจำนวน address ของ IPv4
- เขียนเป็น hexadecimal หลายกลุ่ม
ใน course นี้ VPC รองรับทั้ง IPv4 และ IPv6
4. CIDR คืออะไร?
หัวข้อที่มีชื่อว่า “4. CIDR คืออะไร?”Classless Inter-Domain Routing (CIDR) ใช้ระบุ range ของ IP addresses สำหรับ network หรือ subnet
ตัวอย่าง:
10.22.0.0/16🖼️ Source figure — Student Guide p.120; full screenshot is kept in the Google Drive master copy.
ส่วน /16 คือ prefix length ที่บอกว่ากี่ bit ใช้เป็น network portion
ภาพจำ:
10.22.0.0/16--------- --Network Prefixเมื่อ prefix เล็กลง เช่น /16 จะมี address มากกว่า /24
เมื่อ prefix ใหญ่ขึ้น เช่น /28 จะมี address น้อยลง
5. CIDR Planning สำคัญยังไง?
หัวข้อที่มีชื่อว่า “5. CIDR Planning สำคัญยังไง?”ก่อนสร้าง VPC ต้องคิดล่วงหน้าว่า workload จะโตแค่ไหน
ถ้าจัด CIDR เล็กเกินไป:
วันนี้มี 20 serversปีหน้าเพิ่ม autoscaling / databases / containers→ IP address ไม่พอถ้าจัดใหญ่เกินไปโดยไม่มีแผน ก็อาจทำให้จัด address space ยากเมื่อเชื่อมหลาย VPC หรือ on-prem networks
Student Guide เน้นว่า CIDR blocks ของ VPC ที่เพิ่มเข้ามาไม่ควร overlap กัน
6. CIDR ของ VPC และ Subnet
หัวข้อที่มีชื่อว่า “6. CIDR ของ VPC และ Subnet”Amazon VPC ใช้ CIDR blocks เพื่อกำหนด address space
ตัวอย่างจาก Student Guide:
VPC: 172.31.0.0/16จากนั้นแบ่งออกเป็น subnet ย่อย เช่น:
Public Subnet 1 : 172.31.0.0/20Public Subnet 2 : 172.31.16.0/20Private Subnet 1: 172.31.32.0/20Private Subnet 2: 172.31.48.0/20แนวคิดคือ:
flowchart TB
VPC[172.31.0.0/16]
VPC --> S1[172.31.0.0/20]
VPC --> S2[172.31.16.0/20]
VPC --> S3[172.31.32.0/20]
VPC --> S4[172.31.48.0/20]
7. Amazon VPC คืออะไร?
หัวข้อที่มีชื่อว่า “7. Amazon VPC คืออะไร?”Amazon Virtual Private Cloud (Amazon VPC) คือ network environment ของเราใน AWS
VPC ถูกสร้างภายใน AWS Region และ resource ต่าง ๆ สามารถ launch เข้า subnet ภายใน VPC ได้
Student Guide หน้า 123 อธิบายว่า VPC ช่วยกำหนด:
- IP address range
- Subnets
- Route tables
- Network connectivity
และสร้าง logical isolation ให้ resources
ภาพจำ:
AWS Region└── VPC ├── Availability Zone A │ ├── Public Subnet │ └── Private Subnet │ └── Availability Zone B ├── Public Subnet └── Private Subnet8. Subnet คืออะไร?
หัวข้อที่มีชื่อว่า “8. Subnet คืออะไร?”Subnet คือช่วง IP address ภายใน VPC ที่เราแบ่งออกมาเพื่อวาง resources
🖼️ Source figure — Student Guide p.124; full screenshot is kept in the Google Drive master copy.
จุดสำคัญ:
- Subnet CIDR ต้องอยู่ภายใน VPC CIDR
- Subnet CIDRs ห้าม overlap กัน
- หนึ่ง subnet อยู่ใน หนึ่ง Availability Zone เท่านั้น
ดังนั้น subnet ไม่ได้ span ข้ามหลาย AZ
9. AWS Reserved IP Addresses ใน Subnet
หัวข้อที่มีชื่อว่า “9. AWS Reserved IP Addresses ใน Subnet”Student Guide หน้า 124 ระบุว่าใน IPv4 subnet AWS จะ reserve IP addresses บางตัว
ตัวอย่าง subnet:
10.0.0.0/24address ที่ไม่สามารถ assign ให้ resource ได้รวมถึง:
10.0.0.0 Network address10.0.0.1 Reserved by AWS for VPC router10.0.0.2 Reserved for DNS10.0.0.3 Reserved by AWS for future use10.0.0.255 Network broadcast address (AWS ไม่รองรับ broadcast ใน VPC)ดังนั้นจำนวน IP ที่ใช้ได้จริงจะน้อยกว่าจำนวน address ทั้งหมดของ CIDR block
10. Public Subnet คืออะไร?
หัวข้อที่มีชื่อว่า “10. Public Subnet คืออะไร?”Student Guide หน้า 125 อธิบาย public subnet ว่าเป็น subnet ที่รองรับ resources ซึ่งต้องสื่อสาร inbound/outbound กับ Internet
การทำให้ subnet ใช้งาน Internet ได้ต้องมีองค์ประกอบสำคัญ:
- Internet Gateway attach กับ VPC
- Route Table มี route ไป Internet Gateway
- Resource ต้องมี public IP address ที่เหมาะสมสำหรับการสื่อสารผ่าน Internet
Mental model:
flowchart LR
EC2[EC2 in Public Subnet]
EC2 --> RT[Route Table]
RT -->|0.0.0.0/0| IGW[Internet Gateway]
IGW --> INTERNET[Internet]
การมีชื่อว่า “Public Subnet” ไม่ได้เกิดจากชื่อ subnet แต่เกิดจาก routing configuration
11. Internet Gateway (IGW)
หัวข้อที่มีชื่อว่า “11. Internet Gateway (IGW)”Internet Gateway เป็น VPC component ที่ให้ communication ระหว่าง resource ใน VPC และ Internet
Student Guide ระบุว่า internet gateway มีลักษณะ:
- Horizontally scaled
- Redundant
- Highly available
Internet Gateway ต้อง attach กับ VPC
และ route table ต้องชี้ Internet-bound traffic ไปที่ Internet Gateway
ตัวอย่าง:
Destination Target0.0.0.0/0 igw-xxxx12. Public IPv4 และ NAT ที่ Internet Gateway
หัวข้อที่มีชื่อว่า “12. Public IPv4 และ NAT ที่ Internet Gateway”Student Guide หน้า 126 อธิบายว่า resource ที่ใช้ public IPv4 address มี private IPv4 อยู่ภายใน VPC และ Internet Gateway ทำ address translation ระหว่าง private/public IPv4 ที่ผูกกัน
ภาพจำ:
Inside VPCPrivate IP: 172.31.1.15 | | Internet Gateway translation vPublic IP: 203.x.x.x | vInternet13. Route Table คืออะไร?
หัวข้อที่มีชื่อว่า “13. Route Table คืออะไร?”Route Table คือชุดของ routing rules ที่ใช้ตัดสินใจว่าจะส่ง network traffic ไปที่ไหน
ทุก VPC จะมี main route table
ตัวอย่าง route table:
Destination Target172.31.0.0/16 local0.0.0.0/0 igw-xxxxความหมาย:
172.31.0.0/16 -> traffic ภายใน VPC ส่ง local0.0.0.0/0 -> traffic อื่น ๆ ส่งออก Internet Gateway14. Subnet Association กับ Route Table
หัวข้อที่มีชื่อว่า “14. Subnet Association กับ Route Table”Subnet ต้อง associate กับ route table
ถ้าเราไม่ได้ explicit associate subnet กับ custom route table ระบบจะใช้ main route table ของ VPC
แนวทางทั่วไปจึงเป็น:
Public Subnet ↓Public Route Table ↓Internet Gatewayและ
Private Subnet ↓Private Route Table ↓NAT Gateway15. Private Subnet คืออะไร?
หัวข้อที่มีชื่อว่า “15. Private Subnet คืออะไร?”Private subnet ใช้สำหรับ resources ที่ไม่ควรถูกเข้าถึงโดยตรงจาก Internet
ตัวอย่าง workload:
- Application servers ภายใน
- Database servers
- Backend services
Private subnet ยังสามารถออก Internet ได้แบบ indirect ผ่าน NAT Gateway
flowchart LR
PRIVATE[EC2 in Private Subnet]
PRIVATE --> PRT[Private Route Table]
PRT --> NAT[NAT Gateway]
NAT --> PUBRT[Public Route Table]
PUBRT --> IGW[Internet Gateway]
IGW --> INTERNET[Internet]
16. NAT Gateway คืออะไร?
หัวข้อที่มีชื่อว่า “16. NAT Gateway คืออะไร?”NAT Gateway ใช้ให้ resources ใน private subnet initiate outbound connections ไป Internet โดยไม่ต้อง expose ให้ Internet initiate inbound connection กลับเข้ามาโดยตรง
🖼️ Source figure — Student Guide p.129; full screenshot is kept in the Google Drive master copy.
Student Guide ระบุว่า NAT Gateway:
- ใช้ทำ network address translation
- เป็น managed service
- Horizontally scaled
- Redundant
- Highly available by design
17. NAT Gateway ต้องอยู่ตรงไหน?
หัวข้อที่มีชื่อว่า “17. NAT Gateway ต้องอยู่ตรงไหน?”สำหรับการออก Internet ของ private subnet ตาม architecture ใน Student Guide:
Internet |Internet Gateway |Public Subnet |NAT Gateway |Private Route Table |Private SubnetNAT Gateway อยู่ใน public subnet
และต้องสามารถ route ต่อไปยัง Internet Gateway ได้
18. NAT Gateway Traffic Flow
หัวข้อที่มีชื่อว่า “18. NAT Gateway Traffic Flow”ตัวอย่างจากหนังสือ:
sequenceDiagram
participant EC2 as Private EC2
participant RT as Private Route Table
participant NAT as NAT Gateway
participant IGW as Internet Gateway
participant WEB as Internet Server
EC2->>RT: Request to Internet
RT->>NAT: 0.0.0.0/0 -> NAT Gateway
NAT->>IGW: Translate source address
IGW->>WEB: Forward request
WEB-->>IGW: Response
IGW-->>NAT: Response to NAT public IP
NAT-->>EC2: Translate back to private IP
สิ่งสำคัญคือ private instance ไม่จำเป็นต้องมี public IP เพื่อออก Internet ผ่าน NAT Gateway
19. Connecting Private Subnets to the Internet
หัวข้อที่มีชื่อว่า “19. Connecting Private Subnets to the Internet”Student Guide หน้า 131 สรุป architecture ที่ต้องมีดังนี้:
Private Subnet Route Table0.0.0.0/0 -> NAT Gateway
Public Subnet Route Table0.0.0.0/0 -> Internet Gatewayดังนั้น private route table ไม่ชี้ตรงไป IGW แต่ชี้ไป NAT Gateway ก่อน
20. Elastic Network Interface (ENI)
หัวข้อที่มีชื่อว่า “20. Elastic Network Interface (ENI)”Elastic Network Interface คือ logical network interface ภายใน VPC
มองง่าย ๆ เหมือน virtual NIC ของ EC2
ENI มีข้อมูล network เช่น:
- Private IPv4 address
- Elastic IP association ถ้ามี
- Security groups
- Network attributes อื่น ๆ
Student Guide อธิบายว่า ENI สามารถ detach จาก instance หนึ่งและ attach ไปอีก instance หนึ่งได้ภายใต้ข้อจำกัดที่เกี่ยวข้องกับ Availability Zone
21. ENI Use Cases
หัวข้อที่มีชื่อว่า “21. ENI Use Cases”Student Guide ยกแนวคิดที่ ENI ช่วยได้ เช่น:
- Management network
- Network / security appliance architecture
- Low-budget high-availability solution บางรูปแบบ
ภาพจำ:
EC2-A | ENI |(detach) |EC2-Bเมื่อย้าย ENI network attributes ที่ผูกกับ interface สามารถย้ายไปด้วย
22. Elastic IP Address (EIP)
หัวข้อที่มีชื่อว่า “22. Elastic IP Address (EIP)”Elastic IP address คือ static public IPv4 address สำหรับ dynamic cloud computing
จุดสำคัญจาก Student Guide:
- สามารถ associate กับ instance หรือ network interface
- สามารถ remap ไป instance อื่นใน VPC ได้
- ใช้ช่วยให้ public address คงที่เมื่อ backend instance เปลี่ยน
ตัวอย่าง failover concept:
flowchart LR
EIP[Elastic IP]
EIP --> A[EC2-A]
A -.failure.-> B[EC2-B]
EIP -.remap.-> B
23. VPC Across Multiple Availability Zones
หัวข้อที่มีชื่อว่า “23. VPC Across Multiple Availability Zones”Student Guide แนะนำให้ deploy VPC workloads ข้ามหลาย Availability Zones เพื่อเพิ่ม high availability
🖼️ Source figure — Student Guide p.134; full screenshot is kept in the Google Drive master copy.
ตัวอย่าง:
VPC├── AZ-A│ ├── Public Subnet│ └── Private Subnet│└── AZ-B ├── Public Subnet └── Private Subnetแนวคิดหลัก:
- สร้าง subnet ในแต่ละ AZ
- กระจาย application resources ข้าม AZ
- ใช้ Elastic Load Balancing เพื่อกระจาย traffic
- ให้แต่ละ AZ มีเส้นทาง outbound ที่เหมาะสม
ถ้า AZ หนึ่งมี outage ระบบยังมี resources ในอีก AZ
24. Multi-AZ Networking Mental Model
หัวข้อที่มีชื่อว่า “24. Multi-AZ Networking Mental Model”flowchart TB
INTERNET[Internet]
INTERNET --> IGW[Internet Gateway]
IGW --> ALB[Load Balancer]
ALB --> APP1[App Server - AZ A]
ALB --> APP2[App Server - AZ B]
APP1 --> NAT1[NAT Gateway - AZ A]
APP2 --> NAT2[NAT Gateway - AZ B]
เป้าหมายคือไม่สร้าง dependency ที่ทำให้ AZ เดียวกลายเป็น single point of failure
25. เริ่มเรื่อง VPC Traffic Security
หัวข้อที่มีชื่อว่า “25. เริ่มเรื่อง VPC Traffic Security”หลังจากสร้าง VPC, subnets และ routing แล้ว คำถามต่อไปคือ:
Traffic ไหนควรอนุญาตเข้า/ออก network?
Student Guide เริ่ม security section ด้วย controls สองตัว:
- Network ACL (NACL)
- Security Group (SG)
26. Network ACL (NACL)
หัวข้อที่มีชื่อว่า “26. Network ACL (NACL)”Network Access Control List เป็น optional security layer ระดับ subnet
🖼️ Source figure — Student Guide p.136; full screenshot is kept in the Google Drive master copy.
Student Guide ระบุว่า NACL ทำหน้าที่เป็น firewall ที่ควบคุม inbound และ outbound traffic ของ subnet
คุณสมบัติสำคัญ:
- ทำงานระดับ subnet
- มี inbound rules
- มี outbound rules
- รองรับทั้ง Allow และ Deny
- rules มีหมายเลขและประเมินตามลำดับ
- เป็น stateless
27. NACL Rule Evaluation
หัวข้อที่มีชื่อว่า “27. NACL Rule Evaluation”Rules จะถูก evaluate เริ่มจาก rule number ต่ำไปสูง
ตัวอย่าง:
100 ALLOW TCP 443 from 0.0.0.0/0200 DENY ALL from 0.0.0.0/0ถ้า packet match rule 100 แล้ว ก็ไม่ต้องไล่ต่อไปถึง rule 200
ดังนั้นลำดับ rule สำคัญมาก
28. NACL เป็น Stateless
หัวข้อที่มีชื่อว่า “28. NACL เป็น Stateless”คำว่า stateless หมายถึง inbound และ outbound traffic ถูก evaluate แยกกัน
ถ้าอนุญาต request เข้า:
Inbound ALLOWไม่ได้แปลว่า response จะถูกอนุญาตออกโดยอัตโนมัติ
ต้องมี outbound rule ที่ allow response ด้วย
ภาพจำ:
Inbound Request ↓NACL Inbound Rules
Outbound Response ↓NACL Outbound Rulesสองทิศทางต้องพิจารณาแยกกัน
29. Security Group
หัวข้อที่มีชื่อว่า “29. Security Group”Security Group เป็น virtual firewall สำหรับ instance / network interface
🖼️ Source figure — Student Guide p.137; full screenshot is kept in the Google Drive master copy.
คุณสมบัติสำคัญจาก Student Guide:
- ทำงานระดับ network interface / instance
- ควบคุม inbound และ outbound traffic
- รองรับ Allow rules
- เป็น stateful
30. Security Group เป็น Stateful
หัวข้อที่มีชื่อว่า “30. Security Group เป็น Stateful”ถ้า inbound traffic ได้รับอนุญาตผ่าน SG และ connection ถูก established แล้ว response traffic จะถูก allow กลับออกมาโดยอัตโนมัติ
ตัวอย่าง:
Client ---> TCP 443 ---> EC2 Allowed by SG
EC2 ------ Response ----> Client Automatically allowed as return trafficนี่คือความต่างสำคัญจาก NACL
31. Network ACL vs Security Group
หัวข้อที่มีชื่อว่า “31. Network ACL vs Security Group”| หัวข้อ | Network ACL | Security Group |
|---|---|---|
| ระดับ | Subnet | ENI / Instance |
| Stateful | ไม่ใช่ (Stateless) | ใช่ (Stateful) |
| Allow rules | ได้ | ได้ |
| Deny rules | ได้ | ไม่ใช้ explicit deny rules แบบ NACL |
| Inbound/Outbound | ประเมินแยกกัน | Return traffic ของ established connection ถูกติดตาม |
| Use case | Guardrail ระดับ subnet | ควบคุม access ของ workload |
ประโยคจำง่าย
หัวข้อที่มีชื่อว่า “ประโยคจำง่าย”NACL = ด่านหน้าของ SubnetSG = รปภ.หน้าตัว Server / ENI32. Packet Walkthrough: Public Web Server
หัวข้อที่มีชื่อว่า “32. Packet Walkthrough: Public Web Server”สมมติมี EC2 web server ใน public subnet
flowchart LR
USER[Internet User]
USER --> IGW[Internet Gateway]
IGW --> RT[Public Route Table]
RT --> NACL[Subnet NACL]
NACL --> SG[Security Group]
SG --> ENI[ENI]
ENI --> EC2[EC2 Web Server]
แนวคิดคือ traffic ต้องผ่านหลาย configuration ที่เกี่ยวข้องก่อนถึง workload
33. Packet Walkthrough: Private Server ออก Internet
หัวข้อที่มีชื่อว่า “33. Packet Walkthrough: Private Server ออก Internet”flowchart LR
EC2[Private EC2]
EC2 --> SG[Security Group]
SG --> NACL1[Private Subnet NACL]
NACL1 --> PRT[Private Route Table]
PRT --> NAT[NAT Gateway]
NAT --> PUBRT[Public Route Table]
PUBRT --> IGW[Internet Gateway]
IGW --> INTERNET[Internet]
การออก Internet ของ private server จึงต่างจาก public server เพราะใช้ NAT Gateway เป็นตัวกลาง
34. Checklist สำหรับออกแบบ VPC เบื้องต้น
หัวข้อที่มีชื่อว่า “34. Checklist สำหรับออกแบบ VPC เบื้องต้น”จากเนื้อหา Part 1 เราสามารถวาง checklist ได้ดังนี้:
Addressing
หัวข้อที่มีชื่อว่า “Addressing”- กำหนด VPC CIDR
- คิด growth ของ workload
- หลีกเลี่ยง CIDR overlap
- แบ่ง subnet CIDRs
Availability
หัวข้อที่มีชื่อว่า “Availability”- ใช้หลาย Availability Zones
- สร้าง subnets แยกตาม AZ
- กระจาย workload
Routing
หัวข้อที่มีชื่อว่า “Routing”- Public route table -> Internet Gateway
- Private route table -> NAT Gateway
Security
หัวข้อที่มีชื่อว่า “Security”- Network ACL ระดับ subnet
- Security Group ระดับ ENI/workload
35. ตัวอย่าง Architecture รวม Part 1
หัวข้อที่มีชื่อว่า “35. ตัวอย่าง Architecture รวม Part 1”flowchart TB
INTERNET[Internet]
IGW[Internet Gateway]
INTERNET <--> IGW
subgraph VPC[VPC 10.0.0.0/16]
subgraph AZA[Availability Zone A]
PUBA[Public Subnet A]
PRIA[Private Subnet A]
NATA[NAT Gateway A]
APPA[Application EC2 A]
end
subgraph AZB[Availability Zone B]
PUBB[Public Subnet B]
PRIB[Private Subnet B]
NATB[NAT Gateway B]
APPB[Application EC2 B]
end
PUBA --> NATA
PUBB --> NATB
PRIA --> APPA
PRIB --> APPB
APPA --> NATA
APPB --> NATB
end
IGW <--> PUBA
IGW <--> PUBB
ภาพนี้รวมแนวคิดจากหน้า 123-134 ของ Student Guide เข้าด้วยกัน
36. สิ่งที่ควรจำจาก Module 3 Part 1
หัวข้อที่มีชื่อว่า “36. สิ่งที่ควรจำจาก Module 3 Part 1”- VPC คือ logical network environment ใน AWS Region
- CIDR ใช้กำหนด IP address range
- Subnet CIDR ต้องอยู่ภายใน VPC CIDR และไม่ overlap
- หนึ่ง subnet อยู่ได้เพียงหนึ่ง Availability Zone
- Public subnet ต้องมี routing ไป Internet Gateway
- Private subnet ออก Internet ได้ผ่าน NAT Gateway
- Route table ตัดสินใจว่าจะส่ง traffic ไป target ใด
- ENI คือ virtual network interface
- Elastic IP คือ static public IPv4 address ที่ remap ได้
- Multi-AZ design เพิ่ม availability
- NACL ทำงานระดับ subnet และเป็น stateless
- Security Group ทำงานระดับ instance/ENI และเป็น stateful
Quick Memory Map
หัวข้อที่มีชื่อว่า “Quick Memory Map”IP/CIDR ↓VPC ↓Subnet ↓Route Table ├── Public -> Internet Gateway └── Private -> NAT Gateway -> Internet Gateway ↓NACL (Subnet / Stateless) ↓Security Group (ENI / Stateful) ↓EC2 / Workloadจบ Module 3: Networking 1 - Part 1
หัวข้อที่มีชื่อว่า “จบ Module 3: Networking 1 - Part 1”Part ถัดไปจะต่อจาก VPC Traffic Security หลังหน้า 137 ไปจนถึงการ review/knowledge check ของ Module 3 ก่อนเริ่ม Module 4: Compute
Architecting on AWS 7.12.4 — Module 3: Networking 1 (Part 2)
หัวข้อที่มีชื่อว่า “Architecting on AWS 7.12.4 — Module 3: Networking 1 (Part 2)”Source: VitalSource Bookshelf — Architecting on AWS 7.12.4 (EN), Student Guide
PDF pages: 138–159
Focus: Security groups, layered network defense, Network ACL comparison, capstone review, and Knowledge Check
1. ต่อจาก Part 1: VPC traffic security
หัวข้อที่มีชื่อว่า “1. ต่อจาก Part 1: VPC traffic security”Part 1 พาเราสร้างเส้นทางของ network ตั้งแต่ VPC, subnet, route table, internet gateway, NAT gateway ไปจนถึง Network ACL และ Security Group แล้ว
Part 2 จะโฟกัสคำถามว่า เมื่อ network เชื่อมต่อได้แล้ว เราจะควบคุมว่า traffic อะไรควรผ่าน และอะไรไม่ควรผ่านอย่างไร
AWS ใช้แนวคิด multiple layers of defense โดย Module นี้เน้น 2 ตัวหลัก:
- Security Group (SG) — ควบคุม traffic ที่ระดับ resource / network interface
- Network ACL (NACL) — ควบคุม traffic ที่ระดับ subnet
flowchart LR
Internet[Internet] --> IGW[Internet Gateway]
IGW --> RT[Route Table]
RT --> NACL[Network ACL\nSubnet boundary]
NACL --> SG[Security Group\nResource boundary]
SG --> EC2[EC2 Instance]
สิ่งสำคัญคือ route table ไม่ใช่ firewall — route table บอกว่า traffic จะไปทางไหน ส่วน SG/NACL เป็นตัวควบคุมว่า traffic ได้รับอนุญาตหรือไม่
2. Default และ New Security Groups
หัวข้อที่มีชื่อว่า “2. Default และ New Security Groups”เมื่อสร้าง Security Group ใหม่ จุดที่ควรจำคือ:
- ไม่มี inbound rule → inbound traffic ไม่ได้รับอนุญาต
- มี outbound rule ที่อนุญาตทั้งหมด → outbound traffic ออกได้ทั้งหมด
นี่เป็นประเด็นที่ Student Guide นำไปถามใน Knowledge Check โดยตรง
จากนั้น administrator ค่อยเพิ่ม inbound rule เฉพาะสิ่งที่ต้องใช้ เช่น:
- Web server: TCP 80 / 443
- Administrator access: SSH 22 หรือ protocol ที่ต้องใช้
- Database: เปิดเฉพาะจาก application tier ไม่ใช่เปิดกว้างจากทุก source
จำ: เปิดเฉพาะสิ่งที่ workload ต้องใช้จริง
3. Custom Security Group Rules
หัวข้อที่มีชื่อว่า “3. Custom Security Group Rules”Security Group สามารถกรอง traffic โดยดูจาก:
- Direction: inbound / outbound
- Protocol
- Port
- Source หรือ Destination
ตัวอย่าง web server:
InboundTCP 80 <- approved sourceTCP 443 <- approved source
Outboundตาม requirement ของ applicationSecurity Group เป็น stateful
หมายความว่า ถ้า request ได้รับอนุญาต response traffic ของ connection นั้นจะถูกติดตามและอนุญาตให้ไหลกลับได้
sequenceDiagram
participant U as User
participant SG as Security Group
participant W as Web Server
U->>SG: TCP 443 request
SG->>W: Allowed by inbound rule
W-->>SG: Response
SG-->>U: Response allowed as return traffic
จุดนี้ต่างจาก Network ACL ซึ่งเป็น stateless
4. Security Group Chaining
หัวข้อที่มีชื่อว่า “4. Security Group Chaining”Student Guide แสดงตัวอย่างการใช้ Security Group เป็น source ของ Security Group อื่น เพื่อบังคับ traffic flow ตาม tier
🖼️ Source figure — Student Guide p.140; full screenshot is kept in the Google Drive master copy.
แนวคิด 3-tier:
flowchart TD
Internet --> WebSG[Web Security Group]
WebSG --> Web[Web Tier]
Web --> AppSG[App Security Group]
AppSG --> App[Application Tier]
App --> DBSG[DB Security Group]
DBSG --> DB[Database Tier]
ตัวอย่าง rule ตามแนวคิดในภาพ:
Web SG allow HTTPS from approved source
App SG allow application traffic from Web SG
DB SG allow database traffic from App SGข้อดีคือ policy ผูกกับ role ของ resource มากกว่าต้อง hard-code IP ของทุก instance
5. Multiple Layers of Defense
หัวข้อที่มีชื่อว่า “5. Multiple Layers of Defense”Student Guide แนะนำให้ป้องกัน infrastructure หลายชั้น
🖼️ Source figure — Student Guide p.141; full screenshot is kept in the Google Drive master copy.
flow โดยย่อ:
Internet |Internet Gateway |Route Table |Network ACL |Subnet |Security Group |Instanceแต่ละชั้นทำหน้าที่ต่างกัน:
- Route table — กำหนดเส้นทาง
- Network ACL — subnet-level filtering
- Security Group — resource-level filtering
แนวคิดคือถ้าการตั้งค่าชั้นหนึ่งผิด อีกชั้นยังช่วยลด exposure ได้
6. Security Group vs Network ACL
หัวข้อที่มีชื่อว่า “6. Security Group vs Network ACL”นี่คือหัวข้อสำคัญที่สุดของ Part 2
🖼️ Source figure — Student Guide p.142; full screenshot is kept in the Google Drive master copy.
| หัวข้อ | Security Group | Network ACL |
|---|---|---|
| ระดับที่ผูก | Network interface / resource | Subnet |
| State | Stateful | Stateless |
| Rule | Allow rules | Allow และ Deny rules |
| การประเมิน | ใช้ rules ที่เกี่ยวข้อง | ประเมินตามหมายเลข rule จากต่ำไปสูง |
| ขอบเขต | Resource ที่ผูก SG | Resources ใน subnet ที่ใช้ NACL |
| Default ที่บทนี้เน้น | New SG: inbound none, outbound all | Default NACL allow inbound/outbound; custom NACL deny จนเพิ่ม rule |
วิธีจำง่าย
หัวข้อที่มีชื่อว่า “วิธีจำง่าย”Security Group = Guard หน้าห้องNetwork ACL = Guard หน้าชั้น/โซนหรือ
SG -> Resource levelNACL -> Subnet level7. Stateful vs Stateless
หัวข้อที่มีชื่อว่า “7. Stateful vs Stateless”Security Group — Stateful
หัวข้อที่มีชื่อว่า “Security Group — Stateful”ถ้า inbound request ถูกอนุญาต response traffic ของ connection นั้นสามารถไหลกลับได้
Client ---> TCP 443 ---> EC2Client <--- Response --- EC2Network ACL — Stateless
หัวข้อที่มีชื่อว่า “Network ACL — Stateless”NACL ประเมิน inbound และ outbound แยกกัน
Inbound -> ต้อง match rule ที่อนุญาตOutbound -> ต้อง match rule ที่อนุญาตด้วยดังนั้นถ้าใช้ NACL แบบ restrictive ต้องคิดทั้งสองทิศทาง
8. Default vs Custom Network ACL
หัวข้อที่มีชื่อว่า “8. Default vs Custom Network ACL”จาก Student Guide:
Default Network ACL
หัวข้อที่มีชื่อว่า “Default Network ACL”อนุญาต inbound และ outbound IPv4 traffic
Custom Network ACL
หัวข้อที่มีชื่อว่า “Custom Network ACL”เริ่มต้นโดยไม่อนุญาต traffic จนกว่าจะเพิ่ม rule
NACL ใช้ rule number และประเมินจากเลขต่ำขึ้นสูง เมื่อเจอ rule ที่ match แล้วจะใช้ผลของ rule นั้น
ตัวอย่าง conceptual rules:
100 ALLOW TCP 443 0.0.0.0/0200 DENY ALL 0.0.0.0/0traffic TCP 443 ที่ match rule 100 จะใช้ผลของ rule 100
9. Capstone Architecture Check-in
หัวข้อที่มีชื่อว่า “9. Capstone Architecture Check-in”หน้า 146–147 นำ networking ทั้ง Module มารวมใน architecture เดียว
🖼️ Source figure — Student Guide p.146; full screenshot is kept in the Google Drive master copy.
ภาพนี้ใช้ทบทวนการออกแบบ network หลัก ๆ เช่น:
- VPC เดียวใน Region
- หลาย Availability Zones
- แยก public / application / database subnet
- Internet Gateway
- NAT Gateway
- Route tables
- Security controls
Student Guide ระบุด้วยว่าภาพมี service บางตัวที่ยังไม่ได้อธิบายใน Module นี้ เช่น Elastic Load Balancing, Amazon EFS, Amazon Aurora และ Amazon ElastiCache ดังนั้น Note นี้ไม่ขยาย service เหล่านั้นเกินจากที่ source ให้มา
10. Design Decisions จาก Capstone
หัวข้อที่มีชื่อว่า “10. Design Decisions จาก Capstone”10.1 High Availability
หัวข้อที่มีชื่อว่า “10.1 High Availability”วาง subnet ในหลาย Availability Zones เพื่อไม่ผูก workload ทั้งระบบไว้กับ AZ เดียว
AZ 1: Public + Application + DatabaseAZ 2: Public + Application + Database10.2 Internet-facing resources
หัวข้อที่มีชื่อว่า “10.2 Internet-facing resources”Internet Gateway เชื่อม VPC กับ Internet และ public subnet มี route ที่เหมาะสมไปยัง IGW
10.3 Private resources
หัวข้อที่มีชื่อว่า “10.3 Private resources”application/database tiers สามารถอยู่ใน private subnet เพื่อไม่รับ unsolicited inbound traffic จาก Internet โดยตรง
10.4 Outbound Internet จาก Private Subnet
หัวข้อที่มีชื่อว่า “10.4 Outbound Internet จาก Private Subnet”ใช้ NAT Gateway ใน public subnet
Private instance |Private route table |NAT Gateway |Internet Gateway |Internetprivate resource สามารถ initiate connection ออกไปได้ แต่ NAT Gateway ไม่ได้ใช้รับ unsolicited inbound connection จาก Internet ไปหา private instance
10.5 Traffic filtering
หัวข้อที่มีชื่อว่า “10.5 Traffic filtering”ใช้ทั้ง:
NACL -> subnet boundarySG -> resource boundaryเป็น layered defense
11. Module 3 Review
หัวข้อที่มีชื่อว่า “11. Module 3 Review”Student Guide สรุป Module 3 เป็น 3 หัวข้อหลัก:
- IP addresses
- VPC fundamentals
- VPC traffic security
ถ้าจะจำ Module นี้เป็นภาพเดียว:
flowchart LR
CIDR[IP / CIDR] --> VPC[VPC]
VPC --> SUB[Subnets]
SUB --> ROUTE[Route Tables]
ROUTE --> IGW[Internet Gateway]
ROUTE --> NAT[NAT Gateway]
SUB --> NACL[Network ACL]
NACL --> SG[Security Group]
SG --> RESOURCE[AWS Resource]
12. Knowledge Check
หัวข้อที่มีชื่อว่า “12. Knowledge Check”Question 1
หัวข้อที่มีชื่อว่า “Question 1”True or False: A single Amazon Virtual Private Cloud (Amazon VPC) can span multiple Regions.
Answer: False
Student Guide อธิบายว่า Amazon VPC span Availability Zones ภายใน หนึ่ง Region ไม่ได้ span หลาย Regions
Question 2
หัวข้อที่มีชื่อว่า “Question 2”Which action must be taken to make a subnet public?
Answer: Route outbound traffic to the internet gateway.
ใน public subnet route table ต้องมี route สำหรับ traffic ที่ต้องไป Internet เช่น:
0.0.0.0/0 -> Internet GatewayQuestion 3
หัวข้อที่มีชื่อว่า “Question 3”Which function does the NAT gateway serve?
Answer: Allows internet traffic initiated by private subnet instances.
ประโยคสำคัญคือ initiated by private subnet instances
Question 4
หัวข้อที่มีชื่อว่า “Question 4”What should be used to create traffic filtering rules for a subnet?
Answer: Network access control list (Network ACL)
เพราะ NACL ทำงานในระดับ subnet
Question 5
หัวข้อที่มีชื่อว่า “Question 5”Which ports are open by default when a new security group is created? (Select TWO.)
คำตอบใน Student Guide:
- Nothing is allowed inbound
- Anything is allowed outbound
🖼️ Source figure — Student Guide p.158; full screenshot is kept in the Google Drive master copy.
13. Cheat Sheet — Networking 1
หัวข้อที่มีชื่อว่า “13. Cheat Sheet — Networking 1”VPC= Virtual network in one AWS Region
Subnet= IP range inside VPC= Belongs to one Availability Zone
Public Subnet= Has routing to Internet Gateway
Private Subnet= No direct Internet route through IGW
Internet Gateway= Connects VPC with Internet
NAT Gateway= Allows private subnet resources to initiate outbound connections
Route Table= Decides where traffic goes
Security Group= Stateful= Resource / network-interface level= Allow rules
Network ACL= Stateless= Subnet level= Allow + Deny rules= Evaluated by rule number14. Mental Model สำหรับวิเคราะห์ AWS Network
หัวข้อที่มีชื่อว่า “14. Mental Model สำหรับวิเคราะห์ AWS Network”เวลาเจอ architecture ให้ไล่ถามตามนี้:
1. Resource อยู่ VPC ไหน?2. อยู่ subnet อะไร?3. Subnet อยู่ Availability Zone ไหน?4. Route table ส่ง traffic ไป target ไหน?5. ถ้าต้องออก Internet ใช้ IGW หรือ NAT Gateway?6. NACL อนุญาต traffic นี้หรือไม่?7. Security Group อนุญาต traffic นี้หรือไม่?ถ้าไล่ลำดับนี้ได้ จะเห็น packet flow เป็นระบบกว่าการจำชื่อ service แยก ๆ
End of Module 3 — Networking 1
หัวข้อที่มีชื่อว่า “End of Module 3 — Networking 1”Module 3 covered PDF pages: 114–159
🔬 อ่านเจาะลึกและฝึกเพิ่ม (ไม่บังคับ)
หัวข้อที่มีชื่อว่า “🔬 อ่านเจาะลึกและฝึกเพิ่ม (ไม่บังคับ)”เรียนบทหลักตามลำดับ ส่วนลิงก์ด้านล่างเป็นเนื้อหาเสริมหรือแบบฝึก ไม่จำเป็นต้องทำทั้งหมดก่อนบทถัดไป หากต้องการเจาะลึกหรือลงมือทำ ให้เลือกเปิดเฉพาะสิ่งที่เกี่ยวข้องกับเป้าหมาย
🧪 Companion Labs — ไม่ใช่ Official Google Skills Grader
🛠️ Optional Portfolio Projects — เลือกทำเพื่อประสบการณ์ ไม่ใช่ข้อบังคับก่อนสอบ
เมื่ออ่านและฝึกทบทวนจบแล้ว ทำเครื่องหมายเพื่อบันทึกใน Browser นี้