≡ Menu

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:

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

Share this tutorial on:
{ 6 comments… add one }
  • Zdenek StyblikApril 14, 2010, 10:27 am

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

    • nixCraftApril 14, 2010, 11:10 am

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

  • rikApril 14, 2010, 11:56 am

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

  • RanApril 15, 2010, 8:07 am

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

  • dapxinApril 18, 2010, 11:00 pm

    pretty darn useful stuff. kiu.

  • buxtinMay 15, 2015, 2:15 pm

    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

Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , , , , , ,