Spanning Tree Protocol: ป้องกัน Loop ใน Network ด้วย STP RSTP MSTP

Spanning Tree Protocol: ป้องกัน Loop ใน Network ด้วย STP RSTP MSTP

Spanning Tree Protocol: ป้องกัน Loop ใน Network ด้วย STP RSTP MSTP

ใน network ที่มี switches หลายตัวเชื่อมต่อกัน ถ้ามี redundant links (สายเชื่อมต่อมากกว่า 1 เส้นระหว่าง switches) จะเกิด switching loop ที่ทำให้ broadcast frames วนไปมาไม่มีที่สิ้นสุด bandwidth ถูกใช้หมด switch CPU พุ่ง 100% network ล่มทั้งหมดภายในไม่กี่วินาที

Spanning Tree Protocol (STP) ป้องกัน loop โดย logically block redundant links ไว้ ให้เหลือเส้นทางเดียว (tree topology) ระหว่าง switches ทุกตัว เมื่อ active link เสียหาย STP จะ unblock redundant link ให้ traffic วิ่งเส้นทางสำรองอัตโนมัติ ทุก managed switch มี STP enable อยู่แล้วเป็น default แต่ถ้าไม่เข้าใจ STP อาจตั้งค่าผิดทำให้ network ช้าหรือล่มได้

STP ทำงานอย่างไร

Root Bridge Election

STP เลือก Root Bridge (switch 1 ตัวที่เป็นศูนย์กลางของ tree) โดยดูจาก Bridge Priority + MAC Address ค่า Bridge Priority default = 32768 switch ที่มี priority ต่ำที่สุดจะเป็น Root Bridge ถ้า priority เท่ากัน ดูจาก MAC Address ที่ต่ำสุด ควรกำหนด Root Bridge เอง (ตั้ง priority ให้ต่ำ) ไม่ควรปล่อยให้เลือกอัตโนมัติ เพราะอาจได้ switch ที่ไม่เหมาะสม (เช่น access switch แทนที่จะเป็น core switch)

Port Roles

STP กำหนด role ให้แต่ละ port: Root Port port ที่มี cost ต่ำที่สุดไปยัง Root Bridge (มี 1 port ต่อ switch) Designated Port port ที่ forward traffic ไปยัง segment นั้น (มี 1 port ต่อ segment) Blocked Port port ที่ถูก block เพื่อป้องกัน loop ไม่ forward traffic

Port States (STP Classic)

State ระยะเวลา ส่ง/รับ Data เรียนรู้ MAC ส่ง/รับ BPDUs
Blocking 20 วินาที (max age) ไม่ ไม่ รับเท่านั้น
Listening 15 วินาที (forward delay) ไม่ ไม่ ส่งและรับ
Learning 15 วินาที (forward delay) ไม่ ใช่ ส่งและรับ
Forwarding ใช่ ใช่ ส่งและรับ
Disabled ไม่ ไม่ ไม่

ปัญหาของ STP Classic คือ convergence ช้ามาก เมื่อ topology เปลี่ยน (link down/up) ต้องรอ 30-50 วินาที (blocking → listening → learning → forwarding) กว่า traffic จะวิ่งได้ ในระหว่างนั้น network จะ partial outage

RSTP: Rapid Spanning Tree Protocol

ทำไมต้อง RSTP

RSTP (IEEE 802.1w) ปรับปรุง STP ให้ convergence เร็วขึ้นมาก จาก 30-50 วินาทีเหลือ 1-2 วินาที ด้วย proposal/agreement mechanism ที่ negotiate port roles อย่างรวดเร็ว RSTP เป็น default บน switches รุ่นใหม่ส่วนใหญ่ backward compatible กับ STP Classic

Port Roles เพิ่มเติม

RSTP เพิ่ม port roles: Alternate Port (backup สำหรับ Root Port เปลี่ยนเป็น Root Port ได้ทันทีเมื่อ Root Port ล่ม) Backup Port (backup สำหรับ Designated Port บน segment เดียวกัน)

MSTP: Multiple Spanning Tree Protocol

ปัญหาของ STP/RSTP

STP และ RSTP สร้าง spanning tree เดียว สำหรับทั้ง network หมายความว่า redundant links ที่ถูก block จะไม่ถูกใช้เลย bandwidth เสียเปล่า ถ้ามี VLANs หลายตัว traffic ทุก VLAN วิ่งเส้นทางเดียวกัน

MSTP แก้ปัญหาอย่างไร

MSTP (IEEE 802.1s) สร้าง spanning tree instances หลายตัว map VLANs เข้ากับ instances ต่างกัน ทำให้ VLANs ต่างกันใช้เส้นทางต่างกัน redundant links ถูกใช้งาน ใช้ bandwidth ได้เต็มประสิทธิภาพ load balance traffic ข้าม links ได้

ตารางเปรียบเทียบ STP Variants

Protocol Standard Convergence Instances เหมาะกับ
STP (Classic) 802.1D 30-50 วินาที 1 Legacy networks
RSTP 802.1w 1-2 วินาที 1 Networks ทั่วไป
PVST+ (Cisco) Cisco proprietary 30-50 วินาที 1 per VLAN Cisco-only networks
Rapid PVST+ (Cisco) Cisco proprietary 1-2 วินาที 1 per VLAN Cisco networks ที่ต้อง per-VLAN
MSTP 802.1s 1-2 วินาที Multiple (configurable) Multi-vendor, enterprise

Best Practices สำหรับ STP

กำหนด Root Bridge เอง

อย่าปล่อยให้ STP เลือก Root Bridge เอง ตั้ง core switch เป็น Root Bridge (priority 4096 หรือ 8192) ตั้ง distribution switch เป็น Secondary Root Bridge (priority 8192 หรือ 16384) ใช้คำสั่ง spanning-tree vlan X root primary/secondary บน Cisco

เปิด PortFast บน Access Ports

PortFast ทำให้ access ports (ที่ต่อกับ PC, printer) เข้าสู่ forwarding state ทันทีโดยไม่ต้องรอ STP convergence ป้องกัน DHCP timeout ที่เกิดจากการรอ STP 30 วินาที เปิดเฉพาะ access ports เท่านั้น ห้ามเปิดบน trunk ports (อาจทำให้เกิด loop)

เปิด BPDU Guard

BPDU Guard ปิด port ทันทีที่ได้รับ BPDU (Spanning Tree packet) เปิดบน access ports ที่มี PortFast ป้องกัน rogue switch ที่ถูกต่อเข้า access port ซึ่งอาจทำให้ STP topology เปลี่ยนและ network ล่ม

เปิด Root Guard

Root Guard ป้องกันไม่ให้ port กลายเป็น Root Port เปิดบน ports ที่ต่อกับ downstream switches ที่ไม่ควรเป็น Root Bridge ป้องกัน rogue switch ที่มี priority ต่ำกว่า Root Bridge มาแย่ง Root role

ทิ้งท้าย: STP เป็นเรื่องพื้นฐานที่ต้องเข้าใจ

Spanning Tree Protocol ทำงานเบื้องหลังบน switches ทุกตัว ถ้าไม่เข้าใจ STP อาจตั้งค่าผิดทำให้ network ช้าหรือล่ม ใช้ RSTP หรือ MSTP แทน STP Classic กำหนด Root Bridge เอง เปิด PortFast + BPDU Guard บน access ports เหล่านี้เป็น best practices ที่ต้องทำในทุก network

อ่านเพิ่มเติมเกี่ยวกับ VLAN Configuration และ Network Segmentation ที่ siamlancard.com หรือจาก icafeforex.com และ siam2r.com

อ่านเพิ่มเติม: วิเคราะห์ทองคำ | XM Signal EA

FAQ

Spanning Tree Protocol: ป้องกัน Loop ใน Network ด้วย STP RSTP MSTP คืออะไร?

Spanning Tree Protocol: ป้องกัน Loop ใน Network ด้วย STP RSTP MSTP เป็นหัวข้อสำคัญในวงการเทคโนโลยีที่ช่วยให้การทำงานมีประสิทธิภาพมากขึ้น ไม่ว่าจะเป็นด้าน IT, Network หรือ Server Management

ทำไมต้องเรียนรู้เรื่อง Spanning Tree Protocol: ป้องกัน Loop ใน Network ด้วย STP RSTP MSTP?

เพราะ Spanning Tree Protocol: ป้องกัน Loop ใน Network ด้วย STP RSTP MSTP เป็นทักษะที่ตลาดต้องการสูง และช่วยให้คุณแก้ปัญหาในงานจริงได้อย่างมืออาชีพ การเรียนรู้ตั้งแต่วันนี้จะเป็นประโยชน์ในระยะยาว

Spanning Tree Protocol: ป้องกัน Loop ใน Network ด้วย STP RSTP MSTP เหมาะกับผู้เริ่มต้นไหม?

ได้แน่นอนครับ บทความนี้เขียนให้เข้าใจง่าย เหมาะทั้งผู้เริ่มต้นและผู้มีประสบการณ์ มี step-by-step guide พร้อมตัวอย่างให้ทำตามได้ทันที

Spanning Tree Protocol: ป้องกัน Loop ใน Network ด้วย STP RSTP MSTP — ทำไมถึงสำคัญ?

Spanning Tree Protocol: ป้องกัน Loop ใน Network ด้วย STP RSTP MSTP เป็นหัวข้อสำคัญในวงการ IT ที่ System Admin, Network Engineer และ DevOps Engineer ควรเข้าใจเป็นอย่างดี การรู้เรื่องนี้จะช่วยให้ทำงานได้มีประสิทธิภาพมากขึ้น แก้ปัญหาได้เร็วขึ้น และเป็นทักษะที่ตลาดแรงงานต้องการสูง

เริ่มต้นเรียนรู้ Spanning Tree Protocol: ป้องกัน Loop ใน Network ด้วย STP RSTP MSTP

แนะนำ path การเรียนรู้:

  1. อ่านเอกสาร official — เริ่มจาก documentation ของเครื่องมือ/เทคโนโลยีนั้นๆ
  2. ทำ lab จริง — ตั้ง VM หรือ Docker container แล้วลองทำตาม tutorial
  3. ทำ project จริง — ใช้กับงานจริงหรือ side project เรียนรู้จากปัญหาที่เจอ
  4. อ่าน best practices — ศึกษาว่าคนอื่นใช้งานจริงยังไง มี pitfall อะไร
  5. เข้า community — Reddit, Stack Overflow, Thai IT groups เรียนรู้จากคนอื่น

เครื่องมือที่แนะนำสำหรับ Spanning Tree Protocol: ป้องกัน Loop ใน Network ด้วย STP RSTP MSTP

เครื่องมือ ใช้สำหรับ ราคา
VS Code Code editor หลัก ฟรี
Docker Container + Lab environment ฟรี
Git/GitHub Version control ฟรี
VirtualBox/Proxmox Virtualization สำหรับ lab ฟรี

FAQ — Spanning Tree Protocol: ป้องกัน Loop ใน Network ด้วย STP RSTP MSTP

Spanning Tree Protocol: ป้องกัน Loop ใน Network ด้วย STP RSTP MSTP คืออะไร?

Spanning Tree Protocol: ป้องกัน Loop ใน Network ด้วย STP RSTP MSTP เป็นเทคโนโลยี/ความรู้ด้าน IT ที่ช่วยให้การทำงานมีประสิทธิภาพมากขึ้น อ่านรายละเอียดทั้งหมดในบทความนี้

Spanning Tree Protocol: ป้องกัน Loop ใน Network ด้วย STP RSTP MSTP เหมาะกับผู้เริ่มต้นไหม?

เหมาะครับ บทความนี้อธิบายตั้งแต่พื้นฐาน มี step-by-step guide พร้อมตัวอย่างให้ทำตาม

เรียนรู้ Spanning Tree Protocol: ป้องกัน Loop ใน Network ด้วย STP RSTP MSTP ใช้เวลานานไหม?

พื้นฐานใช้เวลา 1-2 สัปดาห์ ขั้นกลาง 1-3 เดือน ขั้นสูงต้องใช้ประสบการณ์จริง 6 เดือน+

อ่านเพิ่มเติม: SiamLanCard.com | iCafeForex.com | Siam2R.com

รับ EA Semi-Auto ฟรี จาก XM Signal

Best Practices สำหรับ Spanning Tree Protocol: ป้องกัน Loop ใน Network ด้วย STP RSTP MSTP

Spanning Tree Protocol: ป้องกัน Loop ใน Network ด้วย STP RSTP MSTP มี best practices ที่ผู้เชี่ยวชาญแนะนำ:

  • Documentation — จด document ทุกอย่างที่ทำ เพื่อให้คนอื่น (หรือตัวเอง 6 เดือนหลัง) เข้าใจ
  • Version Control — ใช้ Git สำหรับทุก config/code เก็บ history ย้อนกลับได้
  • Automation — automate task ที่ทำซ้ำๆ ด้วย script/Ansible/Terraform
  • Monitoring — ตั้ง monitoring + alerting ให้รู้ปัญหาก่อน user
  • Backup — กฎ 3-2-1 เสมอ 3 copies, 2 media, 1 offsite

ทรัพยากรเรียนรู้เพิ่มเติม

  • Official Documentation — แหล่งเรียนรู้ที่ดีที่สุด อ่าน docs ก่อนเสมอ
  • YouTube Tutorials — ดู video walkthrough เข้าใจเร็วกว่าอ่าน
  • GitHub Examples — ดู code ของคนอื่น เรียนรู้จาก real projects
  • Lab Practice — ตั้ง VM/Docker ฝึกจริง ไม่มีอะไรดีกว่าลงมือทำ

อ่านเพิ่มเติม: iCafeForex | XM Signal EA ฟรี | SiamLanCard | Siam2R

จัดส่งรวดเร็วส่งด่วนทั่วประเทศ
รับประกันสินค้าเคลมง่าย มีใบรับประกัน
ผ่อนชำระได้บัตรเครดิต 0% สูงสุด 10 เดือน
สะสมแต้ม รับส่วนลดส่วนลดและคะแนนสะสม

© 2026 SiamLancard — จำหน่ายการ์ดแลน อุปกรณ์ Server และเครื่องพิมพ์ใบเสร็จ

SiamLancard
Logo
Free Forex EA — XM Signal · SiamCafe Blog · SiamLancard · Siam2R · iCafeFX
iCafeForex.com - สอนเทรด Forex | SiamCafe.net
Shopping cart