Skip to Content
Arista Warrior,第二版
book

Arista Warrior,第二版

by Gary A. Donahue
May 2025
Intermediate to advanced
572 pages
8h 39m
Chinese
O'Reilly Media, Inc.
Book available
Content preview from Arista Warrior,第二版

第 25 章 tcpdump 和高级镜像

本作品已使用人工智能进行翻译。欢迎您提供反馈和意见:translation-feedback@oreilly.com

tcpdump是一款开源的数据包捕获和分析工具,自 20 世纪 80 年代末就已问世。tcpdump 非常有用,因为它允许从命令行进行功能强大的数据包捕获会话。更棒的是,你可以通过 bash 或命令行界面(CLI)使用它。让我们一起来看看。首先,我将向你展示它在 Bash 中的工作原理,然后再向你展示它在 EOS 中的工作原理。

备注

tcpdump 只能捕获以 CPU 为目标或来自 CPU 的数据包。它不会捕获数据平面流量,因为 CPU 不可能全部跟上。大多数交换机都是这种情况。在某些 Arista 交换机上,使用 tcpdump可以看到前面板接口的流量!有关如何使用高级镜像,请参阅本章结尾。

Linux 中的 tcpdump

如果你有 Linux 经验,并且已经知道如何使用 tcpdump,那么在 Bash 中使用它可能会更得心应手。另外,你会发现有时需要在 Bash 中使用它。要这样做,只需进入 Bash,然后就可以了:

Arista-Z#bash

Arista Networks EOS shell

[admin@Arista-Z ~]$ tcpdump -h
tcpdump version 4.9.2
libpcap version 1.8.1
OpenSSL 1.0.2k-fips  26 Jan 2017
Usage: tcpdump [-aAbdDefhHIJKlLnNOPpqStuUvxX#] [ -B size ] [ -c count ]
                [ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]
                [ -i interface ] [ -j tstamptype ] [ -M secret ] [ --number ]
                [ -Q in|out|inout ]
                [ -r file ] [ -s snaplen ] [ --time-stamp-precision precision ]
                [ --immediate-mode ] [ -T type ] [ --version ] [ -V file ]
                [ -w file ] [ -W filecount ] [ -y datalinktype ]
                [ -z postrotate-command ]
                [ -Z user ] [ -@ file_index ] [ expression ]
                *Use -P to print out info from Arista's DCBs (cpudebug interface
                 only)
                *Using -P in combination with -X or -x prints out the DCB's hex
                 and/or ascii representations. This is instead of -x or -X's
                 usual behavior.

在最简单的形式下,tcpdump 显示使用–i 标志指定的接口的数据包信息。需要记住的是,tcpdump 是一条 Linux 命令,因此要查找的是 Linux 接口名称,而不是 EOS 接口名称。我每次使用时都会遇到这种情况。我有时很固执地愚蠢,我妻子就是这么告诉我的:

[admin@Arista-Z ~]$ tcpdump -i e10 tcpdump: e10: ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

A Practical Guide to Fedora™ and Red Hat® Enterprise Linux®, Seventh Edition

A Practical Guide to Fedora™ and Red Hat® Enterprise Linux®, Seventh Edition

Mark G. Sobell

Publisher Resources

ISBN: 9798341658967