Docsity

TCPDUMP Caution, Schemes and Mind Maps of Computer Networks

Toggle sidebar
bg1
1
Network Analyzer 1-1
TCPDUMP
qRefer to book ”Open Source Network
Administration”
mOnline sample chapter:
http://www.phptr.com/articles/article.asp?p=170902&seqNum=4
qSome tools are not based directly on the data
being transmitted on a network, but information
related to that data.
mFor example, network bandwidth values
mSystem logs on network equipment
qSometimes needs to examine the packets
themselves.
mDiagnose some particularly tricky network problems
qWidely used open source tool for directly
analyzing packets: tcpdump
mhttp://www.tcpdump.org/
Network Analyzer 1-2
Caution
qBefore you use tcpdump or other analyzer:
mWill be able to see some private data
mConsult/research Legal implication first
mRespect the privacy of other users
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download TCPDUMP Caution and more Schemes and Mind Maps Computer Networks in PDF only on Docsity!

Network Analyzer 1-

TCPDUMP

q Refer to book ”Open Source Network

Administration”

m Online sample chapter:

http://www.phptr.com/articles/article.asp?p=170902&seqNum=

q Some tools are not based directly on the data

being transmitted on a network, but information

related to that data.

m For example, network bandwidth values

m System logs on network equipment

q Sometimes needs to examine the packets

themselves.

m Diagnose some particularly tricky network problems

q Widely used open source tool for directly

analyzing packets: tcpdump

m http://www.tcpdump.org/

Network Analyzer 1-

Caution

q Before you use tcpdump or other analyzer:

m Will be able to see some private data

m Consult/research Legal implication first

m Respect the privacy of other users

Network Analyzer 1-

What Tcpdump can do for you

q View the entire data portion of an Ethernet frame

or other link layer protocol

m An IP packet

m An ARP packet

m Or any protocol at a higher layer than Ethernet.

q Very useful

m Tcpdump is to a network administrator like a microscope

to a biologist.

m Give a very clear picture of a specific part of your

network

m Can be used when the problem is simply that something is

not working properly.

Network Analyzer 1-

What tcpdump can do for you?

q Case1 : Web browser can not load pages from a

server – it hangs.

m Problem with client? Server? Or between?

m Run tcpdump while loading

  • Watch every stage to see the following
    • DNS query
    • HTTP request to server
    • Server respond

q Case 2: help debug denial of service attacks.

m Tcp show the source address, destination address, type

of traffic, etc.

m Check the packet contents to learn more about the

nature of the attack.

Network Analyzer 1-

Running as root

q Enable promiscuous mode

m How?

m Capture packets that are not addressed to the

interface itself

m Possible degraded performance

q Command line options

m -n :

  • By default tcpdump performs DNS query to lookup

hostname associated with an IP address and uses the

hostname in the output. Look nicer, cause

performance problem.

  • Use –n to disable it.

Network Analyzer 1-

More command line options

m -s snaplen

  • Capture the first 68 bytes by default, enough to grab

the header, not the entire packet.

  • See more data by setting snaplen to be long.
    • For ethernet, how long we can set snaplen?

m -x

  • Print the packet contents in hexadecimal notation.

m -v and –vv

  • Print more info about protocols

m -q

  • Print less info

m -i interface

  • Which one to listen on

Network Analyzer 1-

More command line options

m -e

  • Include Ethernet header

m -l

  • Force tcpdump output to be line buffered.
  • #tcpdump –l | tee tcpdump.out

m -w file and –r

  • Store the data in binary format and then play back as

it were being read from the wire using –r

Network Analyzer 1-

Filters

q Following the command line options is the

expression to dictate exactly which

packets should be captured and which

should be ignored.

q Primitive

m src, dst

  • tcpdump src client.example.com and dst server.example.com

    • Only those packet from “src” and to “dst” m host
  • tcpdump host client.example.com

m Can be combined with and, or and not with parentheses.

  • tcpdump “host client and not (port telnet or port domain)”

Network Analyzer 1-

Understanding the output

q See Unix manpage

q UDP

Time source > destination: udp datalen

Example:

13:45:20.364930 10.7.15.82.2103 > 10.18.0.100.47028: udp 342 (DF)

q TCP

Time source > dest flag sequence [ack ack] win window

[urgent] [options]

Example:

...10.7.21.70.80 > 10.18.0.100.34639: P 1461:2921(1460) ack 973 win 63268 (DF)

Network Analyzer 1-

Viewing Packet Data

q -x print out entire packets in hexadecimal.

q Use an additional program to print character

representations of each byte.

#!/usr/bin/perl

This code is hereby placed in the public domain by its author,

Marc Horowitz. If you use it, it would be polite if you left

my name on it, but there's no requirement.

$| = 1; while(<>) { if (/^\s/) { ($nospc = $_) =~ s/\s+//g; ($spc = $nospc) =~ s/(....)/$1 /g; ($bin = pack("H*",$nospc)) =~ tr/\000-\037\177-\377/./; printf("%16s%-45s%s\n","",$spc,$bin); } else { print; } }

Network Analyzer 1-

Linux# tcpdump -xls 1500 | ./tcpdump-data-filter.pl tcpdump: listening on eth 20:11:35.686269 host.example.com.53454 > c.gtld-servers.net.dom... 4500 003d 9f2a 4000 ff11 add6 0a12 0064 E..=.*@........d c01a 5c1e d0ce 0035 0029 3674 8930 0000 ......5.)6t.0.. 0001 0000 0000 0000 0364 6e73 0765 7861 .........dns.exa 6d70 6c65 0363 6f6d 0000 0100 01 mple.com..... 20:11:35.740531 host.example.com.34243 > web.example.com.80: P ... 4500 03f4 a6f9 4000 4006 5641 0a12 0064 E.....@[email protected] 0a07 154d 85c3 0050 f0b0 2504 41bc a72f ...M...P..%.A../ 5018 60f4 3db0 0000 4745 5420 2f20 4854 P.'.=...GET / HT 5450 2f31 2e30 0d0a 486f 7374 3a20 7765 TP/1.0..Host: we

Network Analyzer 1-

Seeing It All

q Before modern network switch, is was easy

to view all of the traffic on an Ethernet

network.

q On a switched network, what will you see?

tcpdump will be able to view only:

m Traffic destined to your host

m Traffic originated from you host

m Broadcast traffic

m Small random amounts of traffic for other

hosts.

Network Analyzer 1-

Debugging with Tcpdump

q Packet flooding

Linux# tcpdump -n 17:36:16.265220 10.255.255.27.1221 > 10.18.0.100.9995: udp 1168 (DF) 17:36:16.269171 10.255.255.27.1221 > 10.18.0.100.9995: udp 1168 (DF) 17:36:16.273130 10.255.255.23.1221 > 10.18.0.100.9995: udp 1168 (DF) 17:36:16.285228 10.255.255.27.1221 > 10.18.0.100.9995: udp 1168 (DF) 17:36:16.302173 10.255.255.27.1221 > 10.18.0.100.9995: udp 1168 (DF) 17:36:16.319372 10.255.255.27.1221 > 10.18.0.100.9995: udp 1168 (DF) 17:36:16.334600 10.7.15.65.7000 > 10.18.1.140.7001: rx ack (66) (DF) 17:36:16.334975 10.7.15.65.7000 > 10.18.1.140.7001: rx data (36) (DF) 17:36:16.336606 10.255.255.27.1221 > 10.18.0.100.9995: udp 1168 (DF) 17:36:16.336623 10.7.1.70.7000 > 10.18.1.140.7001: rx ack (66) (DF) 17:36:16.336939 10.7.1.70.7000 > 10.18.1.140.7001: rx data (36) (DF) 17:36:16.352253 10.255.255.27.1221 > 10.18.0.100.9995: udp 1168 (DF) 17:36:16.356199 10.255.255.27.1221 > 10.18.0.100.9995: udp 1168 (DF) 17:36:16.396921 10.255.255.27.1221 > 10.18.0.100.9995: udp 1168 (DF)

Network Analyzer 1-

Debugging with Tcpdump

q Webbrowser hangs

m Step 1. Start tcpdump to monitor port 80

#tcpdump host client.example.com and port 80

  • No traffic, so web server is not a problem

m Step 2. Start tcpdump for all

#tcpdump host client.example.com

  • Only DNS request, no response. Linux# tcpdump -xls 1500 host client | ./tcpdump-data-filter.pl 18:14:12.842409 brokenclient.example.com.55313 > dns.example.co... 4500 0048 058b 4000 ff11 9d80 0a12 0064 [email protected] 0a05 061e d811 0035 0034 8a44 e4ca 0010 .......5.4.D.... 0001 0000 0000 0001 0377 7777 0765 7861 .........www.exa 6d70 6c65 0363 6f6d 0000 0f00 0100 0029 mple.com.......) 0800 0000 8000 0000