
Network Troubleshooting ทำไมต้องรู้?
Network Troubleshooting คือกระบวนการวิเคราะห์และแก้ไขปัญหาเครือข่ายอย่างเป็นระบบ เป็นทักษะที่ SysAdmin และ Network Engineer ทุกคนต้องมี เพราะเมื่อเครือข่ายมีปัญหา ทุกอย่างหยุดชะงัก — อีเมลส่งไม่ได้ เว็บเข้าไม่ได้ แอปใช้ไม่ได้ ธุรกิจเสียหายทุกนาที
บทความนี้จะสอนวิธีแก้ปัญหาเครือข่ายอย่างเป็นระบบ ตั้งแต่ Physical Layer จนถึง Application Layer ครอบคลุมเครื่องมือ คำสั่ง และ Methodology ที่ใช้ในงานจริง
OSI Model — กรอบคิดสำหรับ Troubleshooting
ใช้ OSI 7 Layers เป็นแนวทางในการ Troubleshoot จากล่างขึ้นบน (Bottom-up) หรือบนลงล่าง (Top-down):
| Layer | ชื่อ | ปัญหาที่พบบ่อย | เครื่องมือตรวจสอบ |
|---|---|---|---|
| 7 | Application | App crash, API timeout, DNS resolve | curl, wget, nslookup |
| 6 | Presentation | SSL/TLS error, encoding | openssl, ssllabs |
| 5 | Session | Connection timeout, session drop | netstat, ss |
| 4 | Transport | Port blocked, TCP reset, UDP loss | telnet, nc, tcpdump |
| 3 | Network | IP conflict, routing error, ACL | ping, traceroute, ip route |
| 2 | Data Link | MAC duplicate, VLAN error, STP | arp, bridge, ethtool |
| 1 | Physical | สายขาด, port เสีย, power | link light, cable tester |
Methodology: วิธีการแก้ปัญหาอย่างเป็นระบบ
- Identify the Problem: ระบุปัญหาให้ชัดเจน — อะไรที่ไม่ทำงาน? เมื่อไหร่เริ่มไม่ทำงาน? มีอะไรเปลี่ยนแปลงบ้าง?
- Establish a Theory: ตั้งสมมติฐาน — สาเหตุที่เป็นไปได้มีอะไรบ้าง?
- Test the Theory: ทดสอบสมมติฐาน — ใช้เครื่องมือที่เหมาะสม
- Establish a Plan: วางแผนแก้ไข — จะทำอะไร ลำดับไหน
- Implement the Solution: ลงมือแก้ไข
- Verify Functionality: ตรวจสอบว่าปัญหาหมดแล้ว
- Document: บันทึกปัญหาและวิธีแก้ไข
Layer 1: Physical — ตรวจสอบฮาร์ดแวร์
สิ่งที่ต้องตรวจ:
- สาย LAN: เสียบแน่น? สายขาด? ใช้ Cat ถูกประเภท? (Cat5e/Cat6/Cat6a)
- ไฟ LED บน Switch/Router: Link Light ติดไหม? กะพริบ (มี traffic)?
- Power: อุปกรณ์เปิดอยู่? UPS ทำงานปกติ?
- PoE: Power over Ethernet ทำงานปกติ? (สำหรับ AP, IP Camera)
คำสั่ง Linux ตรวจสอบ Physical:
# ดู Link Status ip link show ethtool eth0 # Speed, Duplex, Link detected # ดู Interface Errors ip -s link show eth0 # packets, errors, dropped cat /proc/net/dev # สถิติ interface ทั้งหมด
Layer 2: Data Link — MAC, ARP, VLAN
ปัญหาที่พบบ่อย:
- MAC Address Duplicate: อุปกรณ์ 2 ตัวมี MAC เดียวกัน
- VLAN Misconfiguration: อุปกรณ์อยู่คนละ VLAN เลยคุยกันไม่ได้
- STP Loop: Spanning Tree ทำงานผิดพลาดทำให้ Network loop
- ARP Issues: ARP Cache ผิด หรือ ARP Spoofing
# ดู ARP Table arp -a ip neigh show # ดู MAC Address Table (บน Switch) # Cisco: show mac address-table # Linux Bridge: bridge fdb show # ล้าง ARP Cache sudo ip neigh flush all
Layer 3: Network — IP, Routing, ICMP
เครื่องมือหลัก: ping
# ทดสอบ connectivity ping -c 4 192.168.1.1 # ping gateway ping -c 4 8.8.8.8 # ping Google DNS (ผ่าน internet) ping -c 4 google.com # ทดสอบ DNS + internet # ถ้า ping gateway ไม่ได้ → ปัญหา Layer 1-3 (local network) # ถ้า ping 8.8.8.8 ได้ แต่ ping google.com ไม่ได้ → ปัญหา DNS # ถ้า ping 8.8.8.8 ไม่ได้ แต่ ping gateway ได้ → ปัญหา routing/ISP
traceroute — หา hop ที่มีปัญหา
# Linux traceroute google.com traceroute -n 8.8.8.8 # ไม่ resolve DNS (เร็วกว่า) # MTR (better traceroute) mtr google.com # real-time traceroute + ping mtr -r -c 100 google.com # report mode (100 packets)
IP Configuration
# ดู IP ip addr show ip a # ดู Routing Table ip route show ip route get 8.8.8.8 # ดูว่าจะไปทางไหน # เพิ่ม/ลบ Route sudo ip route add 10.0.0.0/24 via 192.168.1.1 sudo ip route del 10.0.0.0/24 # ตรวจ IP Conflict arping -D -I eth0 192.168.1.100
Layer 4: Transport — TCP/UDP, Ports
ตรวจสอบ Port
# ดู Port ที่เปิดอยู่ ss -tulnp # TCP/UDP listening ports + process netstat -tulnp # แบบเก่า # ทดสอบว่า Port ถูก Block หรือไม่ telnet 192.168.1.100 80 # ทดสอบ TCP port nc -zv 192.168.1.100 443 # netcat test # Scan Port (ด้วย nmap) nmap -sT 192.168.1.100 # TCP connect scan nmap -sU 192.168.1.100 # UDP scan nmap -p 80,443,22 host # scan เฉพาะ port # ดู TCP Connections ss -tn state established # Active connections ss -s # Summary statistics
Packet Capture (tcpdump/Wireshark)
# tcpdump — capture packets sudo tcpdump -i eth0 # capture ทั้งหมด sudo tcpdump -i eth0 port 80 # เฉพาะ HTTP sudo tcpdump -i eth0 host 192.168.1.1 # เฉพาะ host sudo tcpdump -i eth0 -w capture.pcap # save เป็นไฟล์ sudo tcpdump -i eth0 icmp # เฉพาะ ping # อ่าน pcap file tcpdump -r capture.pcap # หรือเปิดด้วย Wireshark เพื่อวิเคราะห์อย่างละเอียด
Layer 7: Application — DNS, HTTP, SSL
DNS Troubleshooting
# ค้นหา DNS nslookup example.com dig example.com dig @8.8.8.8 example.com # ใช้ DNS server เฉพาะ dig example.com +trace # trace DNS resolution path host example.com # ล้าง DNS Cache # Linux: sudo systemd-resolve --flush-caches # Windows: ipconfig /flushdns # Mac: sudo dscacheutil -flushcache # ตรวจ DNS Records dig example.com A # IPv4 dig example.com AAAA # IPv6 dig example.com MX # Mail dig example.com NS # Nameserver dig example.com TXT # TXT records
HTTP/HTTPS Troubleshooting
# ทดสอบ HTTP
curl -v https://example.com # verbose output
curl -I https://example.com # headers only
curl -o /dev/null -w "%{http_code}" https://example.com # status code only
# ทดสอบ SSL Certificate
openssl s_client -connect example.com:443
echo | openssl s_client -connect example.com:443 2>/dev/null | openssl x509 -noout -dates
# วัด Response Time
curl -o /dev/null -s -w "DNS: %{time_namelookup}s\nConnect: %{time_connect}s\nTLS: %{time_appconnect}s\nTotal: %{time_total}s\n" https://example.com
Flowchart: เมื่อ “อินเทอร์เน็ตใช้ไม่ได้”
- ping 127.0.0.1 → ถ้าไม่ได้: TCP/IP Stack เสีย → Reinstall network driver
- ping gateway → ถ้าไม่ได้: ปัญหา Local Network (สาย/Switch/DHCP)
- ping 8.8.8.8 → ถ้าไม่ได้: ปัญหา Routing หรือ ISP
- ping google.com → ถ้าไม่ได้: ปัญหา DNS → เปลี่ยน DNS Server
- curl https://google.com → ถ้าไม่ได้: ปัญหา Firewall/Proxy/SSL
Performance Troubleshooting
Bandwidth Testing
# iperf3 — ทดสอบ bandwidth ระหว่าง 2 เครื่อง # Server: iperf3 -s # Client: iperf3 -c server_ip iperf3 -c server_ip -u # UDP test iperf3 -c server_ip -t 30 # test 30 วินาที iperf3 -c server_ip -P 4 # 4 parallel streams
Latency Analysis
# MTR — continuous traceroute + ping mtr -r -c 100 google.com # ดู Jitter ping -c 100 8.8.8.8 | tail -1 # rtt min/avg/max/mdev = 1.234/2.345/5.678/0.456 ms # mdev คือ jitter — ยิ่งต่ำยิ่งดี
เครื่องมือ Network Monitoring
| เครื่องมือ | ประเภท | ใช้ทำอะไร | ราคา |
|---|---|---|---|
| Wireshark | Packet Analyzer | วิเคราะห์ packet อย่างละเอียด | ฟรี |
| Nagios/Icinga | Monitoring | แจ้งเตือนเมื่อ service ล่ม | ฟรี/เสียเงิน |
| Zabbix | Monitoring | Dashboard + Alert ครบครัน | ฟรี |
| PRTG | Monitoring | ง่าย ครบ SNMP/Flow/Packet | ฟรี (100 sensors) |
| Grafana+Prometheus | Metrics | Dashboard สวย + Alert | ฟรี |
| ntopng | Flow Analyzer | วิเคราะห์ Traffic Flow | ฟรี/เสียเงิน |
| nmap | Scanner | Scan port + service detection | ฟรี |
Common Issues + Solutions (สถานการณ์จริง)
ปัญหา: เว็บช้ามาก
- ตรวจ DNS resolve time:
dig example.com - ตรวจ Server response:
curl -w "%{time_total}" example.com - ตรวจ Bandwidth:
iperf3 -c server - ตรวจ Packet Loss:
mtr server - ตรวจ Server Load:
top,vmstat
ปัญหา: SSH เข้าไม่ได้
- ping server ได้ไหม? → ถ้าไม่ได้ ปัญหา network
telnet server 22→ port เปิดไหม?- ดู
/var/log/auth.log→ ถูก ban โดย fail2ban? - ตรวจ firewall:
ufw statusหรือiptables -L - ตรวจ sshd:
systemctl status sshd
ปัญหา: อุปกรณ์ได้ IP ไม่ถูก
- ตรวจ DHCP Server ทำงานอยู่ไหม
- ดู DHCP Lease:
cat /var/lib/dhcp/dhcpd.leases - ตรวจว่ามี Rogue DHCP Server ไหม
- ทดสอบ manual IP → ถ้าใช้ได้ ปัญหา DHCP
Security-related Network Issues
- ARP Spoofing: ตรวจด้วย
arp -aหา MAC ซ้ำ ป้องกันด้วย Static ARP / DAI - DDoS Attack: ตรวจด้วย
ss -sดูจำนวน connections ป้องกันด้วย Rate Limiting / CDN - Port Scan: ตรวจจาก firewall log ป้องกันด้วย IDS/IPS (Suricata, Snort)
- DNS Hijacking: ตรวจด้วย
digเปรียบเทียบ DNS server ต่างๆ
FAQ
Q: เริ่ม Troubleshoot จาก Layer ไหนก่อน?
A: แนะนำ Bottom-up (Layer 1 → 7) สำหรับมือใหม่ สำหรับผู้มีประสบการณ์ ใช้ “Divide and Conquer” — ping 8.8.8.8 ก่อน ถ้าได้ แสดงว่า Layer 1-3 OK แล้วค่อยดู Layer 4-7
Q: ต้องรู้ Wireshark ไหม?
A: ต้อง อย่างน้อยใช้ Filter พื้นฐานได้ เช่น tcp.port==80, ip.addr==192.168.1.1, dns Wireshark เป็นเครื่องมือที่ทรงพลังที่สุดสำหรับ Network Troubleshooting
อ่านบทความที่เกี่ยวข้อง: