There is often a need. I want to see what data is available for my Nic and what data is coming in. In this case, ethereal can be used in the window to capture packets.
Here we will talk about tcpdump, a classic tool in Linux. I used this tool to intercept and print the entire SQL command when I was troubleshooting MySQL.
The command is as follows:
Tcpdump-I eth1-s 0-L-w-DST port 3306 | strings
The execution results include the intercepted SQL statements.
-S refers to the number of bytes dropped by a packet header. By default, the system discards the packet header to indicate the 68 bytes of protocols such as IP addresses. -S 0 indicates not to discard any byte of the packet (not to discard and not to discard) -L line buffer standard output (the result is not directly output to standard output ). The data of the packet captured by tcpdump is directly output to the standard output by default. -W-Raw packets to file rather than parsing and printing them out, write the most original data to the file. Here is "-". "-" Refers to the standard output. -W-means writing the original data to the standard output. Strings is used to display printable characters in the file, that is, to print raw data (raw data) from tcpdump)