Use Tcpdump-related network information

Source: Internet
Author: User

Tcpdump-related network information uses the command line method tcpdump. Its command format is: tcpdump [-adeflnNOpqStvx] [-c quantity] [-F file name] [-I network interface] [-r file name] [-s snaplen] [-T type] [-w file name] [expression] 1. introduction to tcpdump options-a converts the network address and broadcast address into a name;-d converts the code that matches the information package in an Assembly format that people can understand; -dd provides the matching information package code in the format of the C language program segment;-ddd provides the matching information package code in decimal format; -e prints the header information of the data link layer in the output line;-f prints the external Internet address in numbers;-l converts the standard output to the buffer line format; -n does not convert the network address into a name;-t does not print a timestamp in each output line;-v outputs a slightly detailed information, for example, ttl can be included in an IP package. And service type information;-vv outputs detailed message information;-c stops tcpdump after receiving the specified number of packages;-F reads the expression from the specified file, ignore other expressions;-I indicates the network interface of the listener;-r reads packets from the specified file (these packets are generally generated using the-w option ); -w directly writes the package into the file, and does not analyze and print it out.-T directly interprets the listening package as a specified type of message, common types include rpc (Remote process call) and snmp (Simple Network Management Protocol;) 2. the expression of tcpdump is a regular expression. tcpdump uses it as a condition for filtering packets. If a packet meets the expressive condition, the packet will be captured. If no conditions are provided, all information packets on the network will be intercepted. In an expression, the following types of keywords are generally used. One is about the type of keywords, including host, net, and port. For example, host 210.27.48.2 indicates that 210.27.48.2 is a host, net 202.0.0.0 indicates that 202.0.0.0 is a network address, port 23 indicates that the port number is 23. If no type is specified, the default type is host. the second type is the key words for determining the transmission direction, including src, dst, dst or src, dst and src, which indicate the transmission direction. For example, src 210.27.48.2 indicates that the source address in the IP package is 210.27. 48.2, and dst net 202.0.0.0 indicates that the destination network address is 202.0.0.0. If no direction keyword is specified, the src or dst keyword is used by default. The third type is the protocol keyword, which mainly includes fddi, ip, arp, rarp, tcp, udp, and other types. Fddi indicates a specific network protocol on FDDI (Distributed Optical Fiber Data Interface Network). In fact, it is an alias for "ether". fddi and e ther have similar source addresses and destination addresses, therefore, the fddi protocol package can be processed and analyzed as the ether package. The other keywords indicate the Protocol content of the listener package. If no protocol is specified, tcpdump listens to the information packages of all protocols. In addition to these three types of keywords, other important keywords include gateway, broadcast, less, greater, and three logical operations. The non-operation type is 'not ''! ', And the operation is 'and',' & '; or the operation is 'o R',' | '; these keywords can be combined to form a powerful combination condition to meet people's needs. The following are several examples. (1) To intercept all packets received and sent by all 210.27.48.1 hosts: # tcpdump host 210.27.48.1 (2) intercept communication between the host 210.27.48.1 and the host 210.27.48.2 or 210.27.48.3, run the following command: # tcpdump host 210.27.48.1 and \ (210.27.48.2 or 210.27.48.3 \) (3) if you want to obtain the ip package for all hosts except 210.27.48.1 and 210.27.48.2, run the command: # tcpdump ip host 210.27.48.1 and! 210.27.48.2 (4) to obtain the telnet packet received or sent by the host 210.27.48.1, run the following command: # tcpdump tcp port 23 host 210.27.48.1 3. the output result of tcpdump is described below. We will introduce the output information of several typical tcpdump commands (1) use the data link layer header command # tcpdump -- e host ice is a host with linux installed, her MAC address is 0: 90: 27: 58: AF: 1A H219 is a SUN Workstation With a SOLARIC. Its MAC address is 8: 0: 20: 79: 5B: 46. The output result of the previous command is as follows: 21:50:12. 847509 eth0 <8: 0: 20: 79: 5b: 46 0: 90: 27: 58: af: 1a ip 60: h219.33357> ice. telne t 0: 0 (0) ack 22535 win 8760 (DF) Analysis: 21: 50: 12 indicates the display time, 847509 indicates the ID number, eth0 <indicates that the packet is received from the network interface eth0, and eth0> indicates that the packet is sent from the network interface device, 8: 0: 20: 79: 5b: 46 is the MAC address of the host H219, which indicates that it is a packet sent from the source address H219. 0: 90: 27: 58: af: 1a is the MAC address of the host ICE, indicating that the destination address of the data packet is ICE. ip indicates that the data packet is an IP data packet, and 60 indicates the length of the data packet, h219.33357> ice. telnet indicates that the packet is the TELNET (23) port sent from Port 33357 of host H219 to host ICE. ack 22535 indicates to respond to a packet whose serial number is 222535. win 8760 indicates that the size of the sending window is 8760. (2) run the command # tcpdump arp command to output the tcpdump packet: 22:32:42. 802509 e Th0> arp who-has route tell ice (0: 90: 27: 58: af: 1a) 22:32:42. 802902 eth0 <arp reply route is-at 0: 90: 27: 12: 10: 66 (0: 90: 27: 58: af: 1a) Analysis: 22:32:42 is the timestamp, 802509 indicates the ID, eth0> indicates that the packet is sent from the host, arp indicates that the packet is an ARP request packet, and who-has route tell ice indicates that it is the MAC address of the host ICE requesting the host ROUTE. 0: 90: 27: 5 8: af: 1a is the MAC address of the host ICE. (3) The TCP packet output information captured by TCPDUMP is: src> dst: flags data-seqno ack window urgent options src> dst: indicates from the source address to the target address. flags indicates the Flag Information IN the TCP packet, S indicates the SYN mark, F (f in), P (PUSH), R (RST )". "(not marked); data-seqno is the sequence number of data in the data packet, ack is the sequence number expected next time, window is the size of the window that receives the cache, and urgent indicates whether there is an emergency pointer in the data packet. options is an option. (4) The general output information of the UDP packet captured by TCPDUMP is: route. port1> ice. port2: udp lenth UDP is very simple. The output line above indicates a UDP packet sent from the port1 port of the host ROUTE to the port2 port of the host ICE. The type is UDP and the package length is lenth.

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.