tcpdump: Monitor ALL eth1 Traffic Except My Own SSH Session

last updated in Categories ,

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:


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

See also:

man tcpdump


Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

7 comment

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

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

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

  4. tcpdump -i eth0 port 80 and 443 and host not `echo $SSH_CLIENT | awk '{print $1}'` and not host '' and not host '' and not host '' and not host '' >> temp-tcpdump.txt

  5. “>>” 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

    Still, have a question? Get help on our forum!