
Wireshark คืออะไร?
Wireshark คือ Network Protocol Analyzer อันดับ 1 ของโลก ใช้ดักจับและวิเคราะห์ Packet ที่วิ่งผ่าน Network Interface ช่วยให้ IT Admin สามารถ Troubleshoot ปัญหา Network ได้อย่างรวดเร็ว ตั้งแต่ปัญหา DNS, HTTP Error, จนถึง Latency และ Packet Loss
Display Filter vs Capture Filter
| ประเภท | ใช้ตอนไหน | Syntax | ตัวอย่าง |
|---|---|---|---|
| Capture Filter | ก่อนเริ่ม Capture (BPF Syntax) | host 192.168.1.1 | จับเฉพาะ Packet จาก/ไป IP นี้ |
| Display Filter | หลัง Capture (Wireshark Syntax) | ip.addr == 192.168.1.1 | แสดงเฉพาะ Packet จาก/ไป IP นี้ |
# Capture Filter (ใส่ก่อนกด Capture):
# =============================================
# จับเฉพาะ IP:
host 192.168.1.1
# จับเฉพาะ Subnet:
net 192.168.1.0/24
# จับเฉพาะ Port:
port 80
port 443
port 53
# จับเฉพาะ TCP:
tcp port 80
# ผสม:
host 192.168.1.1 and port 80
host 192.168.1.1 and not port 22
# Display Filter (ใส่ใน Filter Bar หลัง Capture):
# =============================================
# ใช้ Wireshark Syntax (ต่างจาก Capture Filter!)
# → มี AutoComplete ช่วย
# → กรอง Real-time ได้
Display Filters พื้นฐาน
# =============================================
# IP Filters:
# =============================================
ip.addr == 192.168.1.1 # Source หรือ Destination
ip.src == 192.168.1.1 # Source Only
ip.dst == 192.168.1.1 # Destination Only
ip.addr == 192.168.1.0/24 # Subnet
!(ip.addr == 192.168.1.1) # ไม่ใช่ IP นี้
# =============================================
# Protocol Filters:
# =============================================
tcp # TCP Only
udp # UDP Only
icmp # ICMP (Ping)
arp # ARP
dns # DNS
http # HTTP
tls # TLS/SSL
dhcp # DHCP
ssh # SSH
# =============================================
# Port Filters:
# =============================================
tcp.port == 80 # TCP Port 80
tcp.port == 443 # HTTPS
tcp.dstport == 3306 # MySQL Destination
udp.port == 53 # DNS
tcp.port in {80, 443, 8080} # Multiple Ports
# =============================================
# Combination Filters:
# =============================================
ip.addr == 192.168.1.1 and tcp.port == 80
ip.src == 10.0.0.1 and ip.dst == 10.0.0.2
http and ip.addr == 192.168.1.100
dns and ip.addr == 8.8.8.8
tcp.port == 443 and ip.dst == 192.168.1.1
HTTP Troubleshooting Filters
# =============================================
# HTTP Filters:
# =============================================
http # All HTTP Traffic
http.request # HTTP Requests Only
http.response # HTTP Responses Only
http.request.method == "GET" # GET Requests
http.request.method == "POST" # POST Requests
http.request.uri contains "api" # URI contains "api"
http.host == "example.com" # Specific Host
http.response.code == 200 # OK
http.response.code == 404 # Not Found
http.response.code >= 400 # All Errors (4xx + 5xx)
http.response.code >= 500 # Server Errors (5xx)
http.content_type contains "json" # JSON Content
# =============================================
# Practical HTTP Troubleshooting:
# =============================================
# หาว่า Request ไหน Error:
http.response.code >= 400
# หา Slow Requests:
http.time > 5
# → แสดง HTTP Request ที่ใช้เวลา > 5 วินาที
# หา Redirect:
http.response.code >= 300 and http.response.code < 400
# ดู POST Data:
http.request.method == "POST" and http.content_type contains "form"
DNS Troubleshooting Filters
# =============================================
# DNS Filters:
# =============================================
dns # All DNS
dns.qry.name == "example.com" # DNS Query for domain
dns.qry.name contains "google" # Domain contains "google"
dns.qry.type == 1 # A Record (IPv4)
dns.qry.type == 28 # AAAA Record (IPv6)
dns.qry.type == 5 # CNAME
dns.qry.type == 15 # MX Record
dns.flags.rcode != 0 # DNS Errors (NXDOMAIN etc.)
dns.flags.rcode == 3 # NXDOMAIN (Domain Not Found)
dns.time > 0.5 # Slow DNS (> 500ms)
# =============================================
# DNS Troubleshooting Scenarios:
# =============================================
# 1. หา DNS Failure:
dns.flags.rcode != 0
# → แสดง DNS Query ที่ Fail (NXDOMAIN, SERVFAIL)
# 2. หา Slow DNS:
dns.time > 1
# → DNS Response > 1 วินาที (ช้าเกินไป)
# 3. ดู DNS Server ที่ใช้:
dns and udp.dstport == 53
# → ดู IP Destination = DNS Server
# 4. หา DNS Tunneling (Security):
dns.qry.name.len > 50
# → Domain Name ยาวผิดปกติ = อาจเป็น DNS Tunneling
TCP Troubleshooting Filters
# =============================================
# TCP Analysis Filters:
# =============================================
tcp.analysis.retransmission # Retransmission (ส่งซ้ำ)
tcp.analysis.duplicate_ack # Duplicate ACK
tcp.analysis.lost_segment # Lost Segment
tcp.analysis.zero_window # Zero Window (Buffer เต็ม)
tcp.analysis.window_full # Window Full
tcp.analysis.reset # TCP Reset
tcp.analysis.flags.syn # SYN (Connection Start)
tcp.analysis.flags.fin # FIN (Connection End)
# TCP Flags:
tcp.flags.syn == 1 and tcp.flags.ack == 0 # SYN Only (New Connection)
tcp.flags.syn == 1 and tcp.flags.ack == 1 # SYN-ACK
tcp.flags.reset == 1 # RST (Connection Reset)
tcp.flags.fin == 1 # FIN (Connection Close)
# =============================================
# TCP Troubleshooting Scenarios:
# =============================================
# 1. หา Packet Loss:
tcp.analysis.retransmission or tcp.analysis.lost_segment
# → มาก = Network มีปัญหา
# 2. หา Latency สูง:
tcp.analysis.ack_rtt > 0.5
# → Round Trip Time > 500ms
# 3. หา Connection Refused:
tcp.flags.reset == 1
# → Server ปฏิเสธ Connection
# 4. หา SYN Flood (DDoS):
tcp.flags.syn == 1 and tcp.flags.ack == 0
# → จำนวน SYN มากผิดปกติ = อาจเป็น Attack
# 5. หา Slow Connection:
tcp.analysis.initial_rtt > 1
# → Initial RTT > 1 วินาที = Connection ช้า
DHCP Troubleshooting
# DHCP Filters:
dhcp # All DHCP
dhcp.type == 1 # DHCP Discover
dhcp.type == 2 # DHCP Offer
dhcp.type == 3 # DHCP Request
dhcp.type == 5 # DHCP ACK
dhcp.type == 6 # DHCP NAK (Refused!)
# =============================================
# DHCP Troubleshooting:
# =============================================
# 1. เครื่องไม่ได้ IP:
dhcp
# → ดูว่ามี Discover → Offer → Request → ACK ครบไหม
# → ถ้าไม่มี Offer = DHCP Server ไม่ตอบ
# → ถ้ามี NAK = IP ถูกปฏิเสธ
# 2. หา Rogue DHCP Server:
dhcp.type == 2
# → ดู Source IP ของ DHCP Offer
# → ถ้ามี IP ที่ไม่ใช่ DHCP Server ของเรา = Rogue!
# 3. IP Conflict:
arp.duplicate-address-detected
# → หา IP ที่มี MAC Address ซ้ำกัน
VoIP/SIP Troubleshooting
# SIP/VoIP Filters:
sip # All SIP
sip.Method == "INVITE" # Call Setup
sip.Method == "BYE" # Call End
sip.Method == "REGISTER" # Registration
sip.Status-Code >= 400 # SIP Errors
rtp # RTP (Voice Data)
# =============================================
# VoIP Troubleshooting:
# =============================================
# 1. หา Call Setup Failure:
sip.Status-Code >= 400
# → 401 Unauthorized, 403 Forbidden, 404 Not Found
# 2. หา Registration Problem:
sip.Method == "REGISTER" or (sip.CSeq.method == "REGISTER")
# 3. Wireshark VoIP Analysis:
# Telephony → VoIP Calls → ดูรายการ Call ทั้งหมด
# Telephony → RTP Streams → ดู Jitter, Packet Loss
# → Jitter > 30ms = คุณภาพเสียงแย่
# → Packet Loss > 1% = เสียงขาดหาย
Security Analysis Filters
# =============================================
# Security Filters:
# =============================================
# 1. หา Port Scan:
tcp.flags.syn == 1 and tcp.flags.ack == 0
# → จำนวน SYN จาก IP เดียวกันไปหลาย Port = Port Scan
# 2. หา ARP Spoofing:
arp.duplicate-address-detected
# → MAC Address เปลี่ยนสำหรับ IP เดิม
# 3. หา Cleartext Passwords:
http.authorization or http.request.method == "POST"
# → ดู Authorization Header หรือ POST Data
# 4. หา TLS Handshake Issues:
tls.handshake.type == 1 # Client Hello
tls.handshake.type == 2 # Server Hello
tls.alert_message # TLS Alert (Error)
# 5. หา ICMP Anomalies:
icmp.type == 3 # Destination Unreachable
icmp.type == 11 # Time Exceeded (Traceroute)
# 6. หา Suspicious Traffic:
frame.len > 1500 # Oversized Packets
tcp.port == 4444 or tcp.port == 5555 # Common Backdoor Ports
Wireshark Tips & Tricks
# =============================================
# Useful Tips:
# =============================================
#
# 1. Follow TCP Stream:
# คลิกขวาที่ Packet → Follow → TCP Stream
# → เห็น Conversation ทั้งหมดของ Connection นั้น
#
# 2. Export Objects:
# File → Export Objects → HTTP
# → ดาวน์โหลดไฟล์ที่ถูกส่งผ่าน HTTP
#
# 3. Statistics:
# Statistics → Conversations → ดูว่าใครคุยกับใคร
# Statistics → Protocol Hierarchy → ดู Protocol Mix
# Statistics → IO Graphs → กราฟ Traffic Over Time
# Statistics → Endpoints → ดู Top Talkers
#
# 4. Coloring Rules:
# View → Coloring Rules → กำหนดสี
# สีแดง = Errors, สีเขียว = Normal
#
# 5. Time Display:
# View → Time Display Format → Seconds Since Previous
# → ดู Response Time ระหว่าง Request/Response
#
# 6. Profile:
# สร้าง Profile สำหรับงานต่าง ๆ
# Edit → Configuration Profiles → New
# → HTTP Debug Profile, DNS Profile, Security Profile
#
# 7. tshark (CLI Version):
# tshark -i eth0 -f "port 80" -Y "http.response.code >= 400"
# → จับ Packet จาก CLI (สำหรับ Server ไม่มี GUI)
Quick Reference Cheat Sheet
| ปัญหา | Filter |
|---|---|
| เว็บเปิดไม่ได้ | dns.flags.rcode != 0 or http.response.code >= 400 |
| เว็บช้า | http.time > 3 or dns.time > 0.5 |
| Packet Loss | tcp.analysis.retransmission |
| Connection Reset | tcp.flags.reset == 1 |
| IP ไม่ได้ (DHCP) | dhcp |
| DNS Problem | dns.flags.rcode != 0 |
| SSL Error | tls.alert_message |
| Port Scan | tcp.flags.syn == 1 and tcp.flags.ack == 0 |
สรุป: Wireshark Filter สำหรับ Network Troubleshooting
Wireshark เป็นเครื่องมือที่ IT Admin ทุกคนต้องใช้เป็น Display Filter ช่วยให้คุณหาปัญหาได้เร็วขึ้น 10 เท่าแทนที่จะนั่งไล่ดู Packet ทีละตัว เริ่มจาก Filter พื้นฐาน (IP, Port, Protocol) แล้วค่อย ๆ เพิ่มความซับซ้อน (TCP Analysis, HTTP Error, DNS Failure) การรู้ Filter ที่ถูกต้องจะทำให้คุณ Troubleshoot Network ได้แบบเร็วทันใจจริง ๆ