# Capture Traffic By An IP Address Or A Network

`tcpdump` can filter out traffic based on IP address, and a Network, examples below.

## Capture Traffic by an IP Address

To capture traffic for an IP address, we can simply use `host` argument.

```bash
sudo tcpdump host 1.1.1.1
```

This will capture both outgoing, and incoming traffic for an IP address, `1.1.1.1` in example above.

## Capture Traffic from one direction

If you only want to capture traffic from one direction, we can use `src` or `dst` argument.

```bash
sudo tcpdump src 1.1.1.1
sudo tcpdump dst 1.1.1.1
```

## Capture Traffic by a Network

To capture traffic from a network or subnet, we can use `net` argument.

```bash
sudo tcpdump net 1.2.3.0/24
```

***Source:*** [***Danielmiessler***](https://danielmiessler.com/study/tcpdump/#protocol)


---

# 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://til.devjugal.com/linux/tcpdump/capture-traffic-by-an-ip-address-or-a-network.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.
