# lab10 Capture Filter (BPF) 예시 모음
# 사용처: tcpdump · Wireshark "Capture Options" 화면 · tshark -f
# 적용 시점: 캡처 중 (커널에서 필터링 → 빠름, 페이로드 디코딩 불가)

# ─── 호스트 / 출발지·목적지 ──────────────────────────────────
host 192.168.1.10
src host 192.168.1.10
dst host 192.168.1.10
host 192.168.1.10 and host 10.0.0.5
not host 192.168.1.10

# ─── 네트워크 ────────────────────────────────────────────────
net 192.168.1.0/24
src net 10.0.0.0/8
dst net 172.16.0.0/12

# ─── 포트 ────────────────────────────────────────────────────
port 80
src port 80
dst port 443
portrange 1000-2000
port 80 or port 443

# ─── 프로토콜 ────────────────────────────────────────────────
tcp
udp
icmp
arp
ip6                                # IPv6
ether proto 0x88cc                 # LLDP 등 raw EtherType

# ─── 조합 ────────────────────────────────────────────────────
tcp port 80
udp port 53
host 10.0.0.1 and port 22
host 10.0.0.1 or host 10.0.0.2
tcp and not port 22
'(tcp port 80 or tcp port 443) and host www.example.com'

# ─── 플래그 (비트마스크 — 어려움) ────────────────────────────
'tcp[tcpflags] & tcp-syn != 0'                     # SYN 포함
'tcp[tcpflags] & (tcp-syn|tcp-ack) == tcp-syn'     # 첫 SYN (ACK 없음)
'tcp[tcpflags] & (tcp-rst|tcp-fin) != 0'           # RST or FIN

# ─── ICMP 타입 ───────────────────────────────────────────────
'icmp[icmptype] == icmp-echo'                       # ping 요청
'icmp[icmptype] == icmp-echoreply'                  # ping 응답
'icmp[icmptype] == icmp-unreach'                    # destination unreachable

# ─── 패킷 사이즈 ─────────────────────────────────────────────
greater 1500                       # 1500 B 초과
less 100                           # 100 B 미만

# ─── VLAN / MPLS ─────────────────────────────────────────────
vlan
vlan 100
mpls

# ─── 자주 쓰는 운영 패턴 ────────────────────────────────────
'tcp port 80 or tcp port 443'                      # 웹 트래픽
'udp port 53'                                       # DNS
'tcp port 22 and host 10.0.0.5'                     # 특정 서버 SSH
'host www.example.com and port 443'                # HTTPS 특정 사이트
'not (host 10.0.0.1 and port 22)'                  # 내 SSH 빼고
