> For the complete documentation index, see [llms.txt](https://viva.gitbook.io/project/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://viva.gitbook.io/project/wang-luo/zhua-bao/tcpdump.md).

# tcpdump

### 安装

```
yum install -y tcpdump
```

### 使用

例子：监听eth0接口

```
tcpdump -i eth0
```

例子：监听192.168.1.1地址，包括来源与目的

```
tcpdump host 127.0.0.1
```

例子：监听来自于192.168.1.1的数据包

```
tcpdump src host 192.168.1.1
```

例子：监听发送到192.168.1.1的数据包

```
tcpdump dst host 192.168.1.1
```

例子：监听8080端口，包括来源与目的

```
tcpdump port 8080
```

例子：监听来自于8080端口的数据包

```
tcpdump src port 8080
```

例子：监听发送到8080的数据包

```
tcpdump dst port 8080
```

例子：监听tcp包

```
tcpdump tcp
```

例子：监听udp包

```
tcpdump udp
```

例子：监听发送到8080端口，来自于192.168.1.1地址的tcp包

```
tcpdump tcp dst port 8080 and src 192.168.1.1
```
