In this small how-to, I’ll show how to capture network traffic from a remote system to analyze it using Wireshark.
All you need is tcpdump on the remote machine, where you want to dump the network traffic off and Wireshark on the computer, you want to use to look at the packets flying around.
I use this setup for checking, whats going on on my IPcop firewall.
First, you need to prepare a named pipe on you monitoring station:
After this, we build up the connection to the remote system, issue the tcpdump command there and direct all outputs to the pipe:
ssh email@example.com "tcpdump -i eth0 -s 0 -U -w - not port 22" > /tmp/pipe
Now switch to another console and start Wireshark, listening to our newly created pipe:
wireshark -k -i /tmp/pipe
After Wireshark has started, the ssh console will ask for roots password. After you entered it, you will see the packets getting listed in Wiresharks main screen.
Used tcpdump options
- -i eth0 specifies the interface to capture from (change to your needs)
- -s 0 sets the packet snapshot lenght it to the default of 65535, for backwards compatibility with recent older versions of tcpdump
- -U writes each incoming packet to the file (or std. out) immediately, instead of waiting until the buffer has filled
- -w – writes to standard output
- not port 22 keeps tcpdump from returning the traffic we create with our ssh connection