LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-03-2009, 08:34 PM   #1
Red Squirrel
Senior Member
 
Registered: Dec 2003
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,325

Rep: Reputation: 54
run tcp dump in continuous loop


I want to loop tcpdump something like this:

Code:
file="aov`date +%m`.cap"

while true
do
tcpdump -c 10 -w ${file} port 2593
done
The only issue with this is it does not seem to append to the file. How would I go about making it append data?

Basically I want to run this indefinably on my server as I have lot of problems with people hacking (Game server) so I want to try and read the packets and detect what people are doing to exploit the game. Speed hacking, etc...

So what is the best way to loop this?
 
Old 03-03-2009, 08:50 PM   #2
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Why not just keep tcpdump running indefinitely, then? In other words, why are you grabbing 10 packets at a time in a loop?
 
Old 03-03-2009, 09:05 PM   #3
Red Squirrel
Senior Member
 
Registered: Dec 2003
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,325

Original Poster
Rep: Reputation: 54
Well 10 was just an example, but what I want to do is have separate log files so I can download them without stopping the process. I would probably save filenames like cap-mar0309-3.cap or something, so it would be by hour.
 
Old 03-03-2009, 10:09 PM   #4
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
This isn't perfect, but one idea is to simply let this run:
# tcpdump -A -w dump-output

Then from time to time you could check it (without stopping it) using:
# tcpdump -r dump-output

---

If you really want separate dump files, then you could move something like this into your while loop:
Code:
file="aov`date +%s`.cap"
The files are likely to be unique that way (so nothing should get overwritten). See the date(1) manpages for formats if you haven't already.
 
Old 03-03-2009, 11:01 PM   #5
Red Squirrel
Senior Member
 
Registered: Dec 2003
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,325

Original Poster
Rep: Reputation: 54
I thought of doing that, though I was hoping to have them by date then unix time stamp. Though I was thinking if I forget about this I'll end up using up all the disk space, so decided to just go with a big rotation instead. Think this should go for a few days especially if I add a filter:

tcpdump -C 500 -W 25 -nn -s 0 -w logs/aovcap &
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
TCP Packet Dump in Server (Socket Progarmming) pooppp Linux - Networking 0 10-17-2008 07:52 AM
Is there an alternate to while(1) loop in the TCP server ? rajat Linux - Networking 1 06-01-2007 03:42 AM
recv() fails, tcp dump says i'm receiving isakmp packets rdarbin Linux - Networking 0 12-21-2005 12:06 PM
Program on boot-up won't stop running in a continuous loop... CanadianSlacker Slackware 6 01-14-2004 01:06 AM
TCP DUMP question sopiaz57 Linux - Security 3 12-30-2003 07:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration