tcpdump: Monitor ALL eth1 Traffic Except My Own SSH Session

I‘m using tcpdump to dump, debug and monitor traffic on a network. However, there is lots of noise and I would like to exclude ssh from my dumps. How do I monitor all traffic except my ssh session?

The tcpdump command displays out the headers of packets on a network interface that match the boolean expression. In other words you can use boolean expression to drop ssh traffic from dumping and monitoring operation using the following syntax:

ADVERTISEMENTS

tcpdump -i eth1  -s 1500 port not 22

You can skip additional ports too:

tcpdump -i eth1  -s 1500 port not 22 and port not 53

You can also use ip or hostname:

tcpdump -i eth1 port not 22 and host 1.2.3.4

See also:

man tcpdump

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
7 comments… add one
  • Zdenek Styblik Apr 14, 2010 @ 10:27

    There are unmatched ‘pre’ tags in the first example.
    And btw, please switch sides of text and banners if possible. :\

    • 🐧 nixCraft Apr 14, 2010 @ 11:10

      Thanks for the heads up and sorry for the mixup. I’ve fixed css issue :)

  • rik Apr 14, 2010 @ 11:56

    It’s also possible to use the service names in /etc/services, like
    # tcpdump -i eth0 “port not ssh”

  • Ran Apr 15, 2010 @ 8:07

    a little more automatic… =)
    tcpdump -i eth0 port not 22 and host not `echo $SSH_CLIENT | awk ‘{print $1}’`

  • dapxin Apr 18, 2010 @ 23:00

    pretty darn useful stuff. kiu.

  • buxtin May 15, 2015 @ 14:15

    tcpdump -i eth0 port 80 and 443 and host not `echo $SSH_CLIENT | awk '{print $1}'` and not host 'tor.sabotage.org' and not host 'sh02.packetderm.com' and not host 'anemone.mooo.com' and not host 'snorky.mixmin.net' >> temp-tcpdump.txt

  • ijnnji Nov 1, 2016 @ 2:01

    “>>” will create a flat file. Why not use “-w” to right a pcap file?

    tcpdump -i enp1s10 not port ssh and not host `hostname -I` -w my_cap.pcap

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.