# tcpdump

* Capture traffic on an interface or all

```
tcpdump -i eth0
tcpdump -i any 
```

* Capture and write to a file

```
tcpdump -i eth0 -w file_name.pcapng
```

* Read packets from a file, do not resolve hosts/ports

```
tcpdump -r file_name.pcapng -n 
```

* Read packets from a file, dont resolve, show as ASCII

```
tcpdump -r file_name.pcapng -n -A
```

### Useful BPF Examples

* Traffic going to or from a host

```
tcpdump -r file_name.pcapng 'host 192.168.1.34'
```

* Traffic coming from host

```
tcpdump -r file_name.pcapng 'src host 192.168.1.34'
```

* Traffic where the source is not a specific host

```
tcpdump -r file_name.pcapng 'not src host 192.168.1.34'
```

* Only ICMP traffic from a sepecifc host

```
tcpdump -r file_name.pcapng 'icmp and (src host 19.168.1.34)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://book.ice-wzl.xyz/tool-guides/tcpdump.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
