Schnellkurs tcpdump: Unterschied zwischen den Versionen

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
 
(2 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 21: Zeile 21:
 
=== Filter mit AND / OR ===
 
=== Filter mit AND / OR ===
 
* TCP auf Port 443 und IP 10.0.0.1:
 
* TCP auf Port 443 und IP 10.0.0.1:
   tcpdump -ni enp0s3 tcp port 443 and host 10.0.0.1
+
   tcpdump -ni enp0s3 tcp port 443 and host 194.59.156.162
  
 
* TCP auf Port 80 oder 443:
 
* TCP auf Port 80 oder 443:
Zeile 31: Zeile 31:
 
* Alles außer ICMP:
 
* Alles außer ICMP:
 
   tcpdump -ni enp0s3 not icmp
 
   tcpdump -ni enp0s3 not icmp
 +
 +
=== Über welches Interface geht der Traffik rein und raus ===
 +
tcpdump -ni any icmp
 +
  tcpdump: WARNING: any: That device doesn't support promiscuous mode
 +
    (Promiscuous mode not supported on the "any" device)
 +
    tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
 +
    listening on any, link-type LINUX_SLL2 (Linux cooked v2), snapshot length 262144 bytes
 +
    10:42:11.307143 enp0s3 Out IP 192.168.6.213 > 1.1.1.1: ICMP echo request, id 40, seq 1, length 64
 +
    10:42:11.321189 enp0s3 In  IP 1.1.1.1 > 192.168.6.213: ICMP echo reply, id 40, seq 1, length 64
 +
  
 
=== Erweiterungen ===
 
=== Erweiterungen ===
Zeile 41: Zeile 51:
 
* Mitschneiden in Datei (für Wireshark):
 
* Mitschneiden in Datei (für Wireshark):
 
   tcpdump -ni enp0s3 -w capture.pcap port 8000
 
   tcpdump -ni enp0s3 -w capture.pcap port 8000
 +
 +
* Auslesen der Datei :
 +
  tcpdump -r capture.pcap
  
 
=== Hinweise ===
 
=== Hinweise ===

Aktuelle Version vom 19. Mai 2026, 14:43 Uhr

Schnellkurs tcpdump mit br0

Einführung in tcpdump mit Fokus auf die Schnittstelle br0 und Filter für ICMP, TCP-Ports, AND/OR-Logik.

Grundlagen

  • Lauschen auf Interface:
 tcpdump -ni enp0s3
  • Nur ICMP-Pakete (z.B. ping):
 tcpdump -ni enp0s3 icmp
  • Nur TCP-Verkehr (alle Ports):
 tcpdump -ni enp0s3 tcp
  • Nur bestimmter TCP-Port (z.B. 80 für HTTP):
 tcpdump -ni enp0s3 tcp port 80
  • Nur bestimmter TCP-Port (z.B. 80 für HTTP) und ASCII Text wird ausgegeben.
 tcpdump -A -ni enp0s3 tcp port 80

Filter mit AND / OR

  • TCP auf Port 443 und IP 10.0.0.1:
 tcpdump -ni enp0s3 tcp port 443 and host 194.59.156.162
  • TCP auf Port 80 oder 443:
 tcpdump -ni enp0s3 tcp port 80 or tcp port 443
  • ICMP oder TCP-Port 22:
 tcpdump -ni enp0s3 icmp or tcp port 22
  • Alles außer ICMP:
 tcpdump -ni enp0s3 not icmp

Über welches Interface geht der Traffik rein und raus

tcpdump -ni any icmp
  tcpdump: WARNING: any: That device doesn't support promiscuous mode
    (Promiscuous mode not supported on the "any" device)
    tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
    listening on any, link-type LINUX_SLL2 (Linux cooked v2), snapshot length 262144 bytes
    10:42:11.307143 enp0s3 Out IP 192.168.6.213 > 1.1.1.1: ICMP echo request, id 40, seq 1, length 64
    10:42:11.321189 enp0s3 In  IP 1.1.1.1 > 192.168.6.213: ICMP echo reply, id 40, seq 1, length 64


Erweiterungen

  • ASCII-Inhalt der Pakete anzeigen:
 tcpdump -ni enp0s3 -A
  • Nur die ersten 20 Pakete:
 tcpdump -ni enp0s3 -c 3 icmp 
  • Mitschneiden in Datei (für Wireshark):
 tcpdump -ni enp0s3 -w capture.pcap port 8000
  • Auslesen der Datei :
 tcpdump -r capture.pcap

Hinweise

  • tcpdump benötigt oft root-Rechte → mit sudo ausführen.
  • Beenden mit [Strg]+[C].
  • Mitschnitte können später mit tcpdump -r capture.pcap angesehen werden.