Home » IPv4 Subnetting Mastery: VLSM, Supernetting และ IP Planning
IPv4 Subnetting Mastery: VLSM, Supernetting และ IP Planning
IPv4 Subnetting Mastery: VLSM, Supernetting และ IP Planning
IPv4 Subnetting เป็นทักษะพื้นฐานที่ network engineer ทุกคนต้องเชี่ยวชาญ Subnetting แบ่ง network ใหญ่ออกเป็น subnets เล็กๆ เพื่อ efficient IP allocation VLSM (Variable Length Subnet Masking) ใช้ subnet masks ขนาดต่างกันใน network เดียวกัน และ Supernetting (CIDR) รวมหลาย networks เข้าด้วยกันเพื่อลด routing table entries
Classful addressing (Class A/B/C) สิ้นเปลือง IP addresses อย่างมาก: ถ้าต้องการ 300 hosts ต้องใช้ Class B (65,534 hosts) → เสีย 65,234 IPs VLSM แก้ปัญหา: allocate subnet ขนาดพอดีกับความต้องการ (เช่น /23 = 510 hosts สำหรับ 300 hosts) Supernetting ลด routing table จาก 1000s routes → ไม่กี่ routes (summarization)
Subnet Mask Reference
| CIDR |
Subnet Mask |
Hosts |
Networks (from /24) |
| /32 |
255.255.255.255 |
1 (host route) |
– |
| /31 |
255.255.255.254 |
2 (point-to-point) |
128 |
| /30 |
255.255.255.252 |
2 usable |
64 |
| /29 |
255.255.255.248 |
6 |
32 |
| /28 |
255.255.255.240 |
14 |
16 |
| /27 |
255.255.255.224 |
30 |
8 |
| /26 |
255.255.255.192 |
62 |
4 |
| /25 |
255.255.255.128 |
126 |
2 |
| /24 |
255.255.255.0 |
254 |
1 |
| /23 |
255.255.254.0 |
510 |
– |
| /22 |
255.255.252.0 |
1,022 |
– |
| /21 |
255.255.248.0 |
2,046 |
– |
| /20 |
255.255.240.0 |
4,094 |
– |
| /16 |
255.255.0.0 |
65,534 |
– |
Subnetting Steps
| Step |
Action |
ตัวอย่าง (192.168.1.0/24 → /26) |
| 1. Determine subnet bits |
/26 – /24 = 2 bits borrowed |
2 bits → 4 subnets |
| 2. Calculate block size |
256 – 192 = 64 (subnet mask last octet) |
Block size = 64 |
| 3. List subnets |
.0, .64, .128, .192 |
4 subnets starting at multiples of 64 |
| 4. Network address |
First address in block |
.0, .64, .128, .192 |
| 5. First usable |
Network + 1 |
.1, .65, .129, .193 |
| 6. Last usable |
Broadcast – 1 |
.62, .126, .190, .254 |
| 7. Broadcast |
Last address in block |
.63, .127, .191, .255 |
VLSM (Variable Length Subnet Masking)
| Feature |
รายละเอียด |
| คืออะไร |
ใช้ subnet masks ขนาดต่างกันใน network เดียวกัน |
| Why |
Allocate เฉพาะ IPs ที่ต้องการ (ไม่ waste เหมือน fixed-length subnetting) |
| Rule |
Start with largest subnet first → then smaller → allocate from remaining space |
| Requirement |
Routing protocol ต้อง support VLSM (OSPF, EIGRP, BGP — not RIPv1) |
VLSM Example
| Department |
Hosts Needed |
Subnet |
CIDR |
Usable Range |
| Engineering |
100 |
10.1.0.0/25 |
/25 (126 hosts) |
10.1.0.1 – 10.1.0.126 |
| Sales |
50 |
10.1.0.128/26 |
/26 (62 hosts) |
10.1.0.129 – 10.1.0.190 |
| HR |
25 |
10.1.0.192/27 |
/27 (30 hosts) |
10.1.0.193 – 10.1.0.222 |
| Management |
10 |
10.1.0.224/28 |
/28 (14 hosts) |
10.1.0.225 – 10.1.0.238 |
| WAN Link 1 |
2 |
10.1.0.240/30 |
/30 (2 hosts) |
10.1.0.241 – 10.1.0.242 |
| WAN Link 2 |
2 |
10.1.0.244/30 |
/30 (2 hosts) |
10.1.0.245 – 10.1.0.246 |
Supernetting (CIDR Summarization)
| Feature |
รายละเอียด |
| คืออะไร |
รวมหลาย contiguous subnets เข้าเป็น 1 summary route (shorter prefix) |
| Purpose |
ลด routing table size → faster lookups → less memory |
| Requirement |
Subnets ต้อง contiguous + start at correct boundary |
| ตัวอย่าง |
192.168.0.0/24 + 192.168.1.0/24 + 192.168.2.0/24 + 192.168.3.0/24 = 192.168.0.0/22 |
Summarization Steps
| Step |
Action |
| 1. List networks |
เขียนทุก networks ที่ต้องการ summarize |
| 2. Convert to binary |
แปลง network addresses เป็น binary |
| 3. Find common bits |
หา bits ที่เหมือนกัน (จากซ้ายไปขวา) |
| 4. Summary = common bits |
Common bits = network part ของ summary route |
| 5. Count common bits |
จำนวน common bits = new prefix length |
IP Planning Best Practices
| Practice |
รายละเอียด |
| Plan for summarization |
Allocate IP blocks ที่ summarize ได้ (contiguous per region/site) |
| Use /31 for P2P links |
RFC 3021: /31 สำหรับ point-to-point links (save IPs) |
| Reserve growth space |
อย่า allocate ที่ subnets ติดกัน → leave room for expansion |
| Document IP allocation |
ใช้ IPAM tool (NetBox, phpIPAM, Infoblox) |
| Consistent addressing |
.1 = gateway, .2-.10 = infrastructure, .11+ = DHCP pool |
| Separate by function |
Management, servers, users, voice, IoT → different subnets |
| Use RFC 1918 |
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 สำหรับ private networks |
Common Subnetting Mistakes
| Mistake |
วิธีแก้ |
| ลืม network + broadcast addresses |
Usable hosts = 2^host_bits – 2 (ลบ network + broadcast) |
| Overlapping subnets |
ตรวจสอบว่า subnets ไม่ overlap (ใช้ IPAM tool) |
| ไม่ plan for growth |
ใช้ subnet ที่ใหญ่กว่าที่ต้องการ 50-100% |
| Non-contiguous allocation |
Allocate contiguous blocks ต่อ site → summarize ได้ |
| ไม่ document |
Document ทุก allocation ใน IPAM (who, what, when) |
ทิ้งท้าย: Subnetting = Foundation of Network Design
IPv4 Subnetting Subnetting: divide network → smaller subnets (efficient IP use) VLSM: variable subnet masks → allocate exactly what’s needed (largest first) Supernetting/CIDR: combine contiguous networks → reduce routing table Key formula: hosts = 2^host_bits – 2, subnets = 2^borrowed_bits Planning: summarizable blocks + /31 for P2P + document in IPAM + room for growth RFC 1918: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16
อ่านเพิ่มเติมเกี่ยวกับ IPv6 Deployment Dual-Stack และ OSPF Advanced Areas LSA ที่ siamlancard.com หรือจาก icafeforex.com และ siam2r.com