Use tcpdump to intercept Linux server-side network data

Source: Internet
Author: User

Syntax Examples:

Tcpdump-vv-i ens3 ' ((TCP) && (host 183.239.240.48) && (port 3001)) '-C 100-w 12.cap

-I indicates a specified network device

The following strings are rules, and the rules are usually so spliced:

"  not "  "and" "or"  

Rule statements have these:

Protocol class:

arp,ip,tcp,udp,icmp

Address class:

Host: source or destination IP

DST Host: Destination IP

SRC Host: Source IP

Port: source or destination. (with DST host, src host, meaning ibid.)

NET: Specifies the network. (There is also DST net, SRC net)

Follow Kanenaga:

Less 100 means fewer than 100

Greater 100 means greater than 100

Advanced filtering:

According to the IP header:

Ip[0]>5

Packet size (2bytes) from the IP header to determine:

ip[2:2]>600

The TCP header can also take the size:

Tcp[0:2]

Block HTTP (not necessarily successful because the head length is not fixed):

0x4745 for "GET" first two letters "GE"

0x4854 to "HTTP" the first two letters "HT"

tcp[20:2]=0x4745 or tcp[20:2]=0x4854

==============================================

You can specify how many packets to grab by using the-c parameter, and then use "-w" to place a text file

Reference article:

Https://www.wains.be/pub/networking/tcpdump_advanced_filters.txt (Chinese translation: http://www.veryarm.com/1751.html#12)

http://packetpushers.net/masterclass-tcpdump-expressions/

https://www.hugeserver.com/kb/install-use-tcpdump-capture-packets/

Https://www.cnblogs.com/ggjucheng/archive/2012/01/14/2322659.html

Use tcpdump to intercept Linux server-side network data

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.