Fórum Root.cz
Hlavní témata => Server => Téma založeno: ATomas 28. 07. 2015, 10:26:08
-
Zdravím,
omlouvám se, pokud jsem to napsal do špatné kategorie. Ale potřeboval bych pomoct s tcpdump
Loguji si přenos dat na mém serveru (linux debian 7) nějak takto:
tcpdump -n -e -i eth0 > /rec.txt
to bez problému funguje, ale má to jeden nedostatek, pokud loguji příliž dlouho, tak soubor je obrovský a je dost časově náročné ho otevřít a poté se v něm pohybovat. Proto bych potřeboval, aby tcpdump logoval do více souborů s menší velikostí. V manuálu jsem se dočetl že to údajně umí přepínač -w ovšem nevím jak to použít. Nemá s tím někdo zkušenosti ? Děkuji.
-
man tcpdump:
-w Write the raw packets to file rather than parsing and printing them out.
-W Used in conjunction with the -C option, this will limit the number of files created to the specified number, and begin overwriting files from the beginning, thus creating a ’rotating’ buffer.
-C Before writing a raw packet to a savefile, check whether the file is currently larger than file_size and, if so, close the current savefile and open a new one. Savefiles after the first savefile
will have the name specified with the -w flag, with a number after it, starting at 1 and continuing upward. The units of file_size are millions of bytes (1,000,000 bytes, not 1,048,576 bytes).
=> takze limit 5MB, max 10 suborov:
tcpdump <...> -C 5 -W 10 -w rec.pcap
Problem s pravami na interface: https://askubuntu.com/questions/530920/tcpdump-permissions-problem
Problem s pravom zapisu (sudo + '-C'): https://github.com/the-tcpdump-group/tcpdump/issues/448
-
A v čem je problém? Man to popisuje naprosto jasně:
tcpdump ... [ -C file_size ] ... [ -w file ]
-C Before writing a raw packet to a savefile, check whether the file is currently larger than file_size and, if
so, close the current savefile and open a new one. Savefiles after the first savefile will have the name spec-
ified with the -w flag, with a number after it, starting at 1 and continuing upward. The units of file_size
are millions of bytes (1,000,000 bytes, not 1,048,576 bytes).
-w Write the raw packets to file rather than parsing and printing them out. They can later be printed with the -r
option. Standard output is used if file is ``-''.
Všimni si, že s "-w" se neukládá textový popis paketů, ale samotná data tak, jak jsou. To je úspornější. Další možnost úspory je vyfiltrovat jenom to, co tě zajímá.
-
Dobře děkuji, funguje to. Ovšem nešlo by nějk nastavit, aby to psalo vystup v té čitelné podobě (myslím ten klasický výstup, který jde číst v txt) ? O místo mi nejde místa na disku mám habaděj.
-
Ovšem nešlo by nějk nastavit, aby to psalo vystup v té čitelné podobě (myslím ten klasický výstup, který jde číst v txt) ?
Ne. Ale když máš ty pcap soubory, tak si je můžeš do čitelné podoby převést tím příkazem, který jsi původně používal, akorát místo "-i eth0" tam dáš "-r my-pcap-file"
-
Skvele funguje to! Dekuju moc vsem za rady. Jste uzasni ! :)