82
52
I want a simple way to show all the TCP data (not the TCP headers or anything else) going over any interface on my Linux box.
For instance, I want a magical command that if I do:
magic_commmand_I_want port=1234
then if there was a server listening on port 1234 on my machine, and someone did:
echo hello | nc localhost 1234
# Note: "nc" (aka "netcat") is a simple tool that sends data to a host/port
Then the magical command would just print out:
hello
I've tried "tcpdump", "ethereal", "tethereal", "tshark", and others, but it isn't obvious how you get them to:
- not show IP addresses or other metadata
- only show the "data" being sent, not individual packets and their headers
- print the data as-is, not in hex, and not with packet-offset markers
- sniff all network traffic (whether it's on eth0 or eth1 or lo, etc...)
Yes, you could probably string together a piped set of unix commands to do this, but that isn't very easy to remember for next time :)
If you have a simple example of an exact command-line that does this, that's what I'd like.
3I know this is an old question but I'm curious to know why using nc for the "server side" as well wasn't an option?
"nc -l 1234" creates a server that listens on port 1234 and prints out whatever is sent to it and closes the connection. If you want to keep the connection alive and not disconnect you can add the "-k" option. – StFS – 2014-08-13T14:20:40.010
2@StFS because he wants to sniff a running port and nc would complain. – infoclogged – 2017-09-06T23:51:07.783
2tcpdump is the magic command you want. Wireshark is a nice GUI on top of the library tcpdump uses – Vinko Vrsalovic – 2009-08-13T22:48:00.057