tcpdump cheat sheet

Packet Capturing OptionsSwitchSyntaxDescription-i anytcpdump -i anyCapture from all interfaces-i eth0tcpdump -ieth0Capture from specific interface ( E

Packet Capturing Options

Switch Syntax Description
-i any tcpdump -i any Capture from all interfaces
-i eth0 tcpdump -ieth0 Capture from specific interface ( Ex Eth0)
-c tcpdump -i eth0 -c 10 Capture first 10 packetsand exit
-D tcpdump -D Show available interfaces
-A tcpdump -i eth0 -A Print in ASCII
-w tcpdump -i eth0 -w tcpdump.txt To save capture to a file
-r tcpdump -r tcpdump.txt Read and analyze savedcapture file
-n tcpdump -n -I eth0 Do not resolve host names
-nn tcpdump -n -i eth0 Stop Domain name translationand lookups (Host names or port names )
tcp tcpdump -i eth0 -c 10 -w tcpdump.pcap tcp Capture TCP packets only
port tcpdump -i eth0 port 80 Capture traffic from a defined port only
host tcpdump host 192.168.1.100 Capture packets from specific host
net tcpdump net 10.1.1.0/16 Capture files from network subnet
src tcpdump src 10.1.1.100 Capture from a specific source address
dst tcpdump dst 10.1.1.100 Capture from a specific destination address
service tcpdump http Filter traffic based on a port number for aservice
port tcpdump port 80 Filter traffic based on a service
port range tcpdump portrange 21-125 Filter based on port range
-S tcpdump -S http Display entire packet
ipv6 tcpdunp -IPV6 Show only IPV6 packets
-d tcpdump -d tcpdump.pcap display human readable form in standardoutput
-F tcpdump -F tcpdump.pcap Use the given file as input for filter
-I tcpdump -I eth0 set interface as monitor mode
-L tcpdump -L Display data link types for the interface
-N tcpdump -N tcpdump.pcap not printing domian names
-K tcpdump -K tcpdump.pcap Do not verify checksum
-p tcpdump -p -i eth0 Not capturing in promiscuous mode

Logical Operators

Operator Syntax Example Description
AND and, && tcpdump -n src 192.168.1.1 and dst port 21 Combine filtering options
OR or, || tcpdump dst 10.1.1.1 && !icmp Either of the condition can match
EXCEPT not, ! tcpdump dst 10.1.1.1 and not icmp Negation of the condition
LESS < tcpdump <32 Shows packets size less than 32
GREATER > tcpdump >=32 Shows packets size greater than 32

Installation Commands

Linux Distro Command
CENT OS and REDHAT $ sudo yum install tcpdump
Fedora $ dnf install tcpdump
Ubuntu, Debian and Linux Mint $ apt-get install tcpdump

Display / Output Options

Switch Description
-q Quite and less verbose modedisplay less details
-t Do not print time stamp details in dump
-v Little verbose output
-vv More verbose output
-vvv Most verbose output
-x Print data and headers in HEX format
-xx Print datawith link headers in HEX format
-X Print output in HEX and ASCII format excluding link headers
-XX Print output in HEX and ASCII format including link headers
-e Print Link (Ethernet) headers
-S Print sequence numbers in exact format

Protocols

Ether, fddi, icmp ,ip, ip6 , ppp, radio, rarp, slip, tcp , udp, wlan

Common Commands with Protocols for Filtering Captures

Options Description
src/ dsthost (host name or IP) Filter by source or destination IP address or host
ether src/ dst host (ethernet host name or IP) Ethernet host filtering by source or destination
src/ dstnet(subnet mask in CIDR) Filter by subnet
tcp/udp src/dst port ( port number) Filter TCP or UDP packets by source or destination port
tcp/udp src/dst port range ( port number range) Filter TCP or UDP packets by source or destination port range
ether/ip broadcast Filter for Ethernet or IP broadcasts
ether/ip multicast Filter for Ethernet or IP multicasts

Read more

容器镜像(4):镜像的常用工具箱

容器镜像(4):镜像的常用工具箱

前几篇在讲多架构镜像时已经用过 skopeo 和 crane 做镜像复制,这篇系统整理这两个工具的完整能力,同时介绍几个日常操作镜像时同样好用的工具。 一、skopeo:不依赖 Daemon 的镜像瑞士军刀 skopeo 的核心价值是绕过 Docker daemon,直接与 Registry API 交互。上一篇用它做镜像复制和离线传输,但它的能力远不止于此。 1.1 安装 # Ubuntu / Debian sudo apt install -y skopeo skopeo --version # skopeo version 1.15.1 1.2 inspect:免拉取检查镜像元数据 docker inspect 需要先把镜像拉到本地,skopeo inspect 直接向 Registry

容器镜像(3):多架构镜像构建

容器镜像(3):多架构镜像构建

一、什么是多架构镜像 1.1 OCI Image Index 上一篇介绍了单平台镜像的结构:一个 Manifest 指向 Config 和若干 Layer blob。多架构镜像在此之上多了一层——OCI Image Index(也叫 Manifest List),是一个轻量的索引文件,把多个单平台 Manifest 组织在一起: $ docker manifest inspect golang:1.22-alpine { "schemaVersion": 2, "mediaType": "application/vnd.oci.image.index.v1+json", "manifests&

容器镜像(2):containerd 视角下的镜像

容器镜像(2):containerd 视角下的镜像

一、为什么需要了解 containerd 如果你只用 docker run 跑容器,从来不关心底层,那可以不了解 containerd。但如果你在用 Kubernetes,或者想真正理解"容器运行时"是什么,containerd 是绕不开的。 事实上,当你执行 docker run 的时候,containerd 早就在后台悄悄工作了——Docker 从 1.11 版本开始,就把核心运行时剥离出来交给 containerd 负责。 1.1 Docker 的架构演变 早期的 Docker(1.10 及之前)是一个"大一统"的单体程序:一个 dockerd