LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-15-2011, 06:52 PM   #1
Fallen_Demon
LQ Newbie
 
Registered: Sep 2009
Location: Australia
Distribution: Ubuntu
Posts: 13

Rep: Reputation: 2
Sniffing traffic passing through iptable rules and spitting out a formatted log


We have a Linux based router routing traffic for a public network. I want to beef up security by closing up some of the ports, but need to know which are in use (there are some crazy applications running, don't want to break them). Is there possibly a way to get cron to run ethereal or tcpdump for a short time, grep the output for new ports and add them to a text file? I'm not very good with awk or sed, so if someone could give me a couple of commands for parsing a line of output I would be very thankful.
 
Old 06-16-2011, 02:52 PM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
use the 'ss' command?

Code:
watch -n 1 ss
To see what is happening at the moment...

Or you could run it every couple of minutes to a file, then later sort and uniq the file to see what services were used.
Code:
Crontab:
*/1 * * * * ss >> /tmp/ss.out
Code:
View uniq services:
cat /tmp/ss.out|cut -c72-|sort|uniq

Last edited by szboardstretcher; 06-16-2011 at 02:57 PM.
 
Old 06-17-2011, 01:45 AM   #3
Fallen_Demon
LQ Newbie
 
Registered: Sep 2009
Location: Australia
Distribution: Ubuntu
Posts: 13

Original Poster
Rep: Reputation: 2
Hrmm, this seems to investigating application sockets on the local machine. Useful for something else I'm doing, but I need something that can sniff the traffic getting forwarded by my iptables rules
 
Old 06-24-2011, 01:17 AM   #4
DJRcomputing
Member
 
Registered: Mar 2011
Location: /usa/pa/manheim
Distribution: Debian 5 + Xfce
Posts: 64

Rep: Reputation: 6
Quote:
Originally Posted by Fallen_Demon View Post
...I need something that can sniff the traffic getting forwarded by my iptables rules
You mean like a "packet sniffer"? Not to be cheeky, but a Synaptic (I see you're Ubuntu) search for said description yields quite a few. I'm trying Wireshark at the moment, but I haven't worked with it enough to be pro/con. Seems promising, though. Snort looked REALLY promising for intrusion detection (slightly OT), but they require a paid subscription for their ruleset. Pass, for now...uninstalled.

In terms of CLI, there are also the commands netstat -lptu & lsof -i. Their outputs may be useful to you.

Last edited by DJRcomputing; 06-25-2011 at 12:21 AM.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
iptable rules, your opinions linuxcbon Linux - Security 7 08-16-2008 05:54 PM
IPTable rules RecoilUK Linux - Security 1 05-27-2005 07:25 PM
Verifying IPTable rules... Ateo Linux - Networking 1 02-02-2005 03:33 PM
Help with IPtable Rules aqoliveira Linux - Security 3 12-10-2003 10:00 AM
sniffing 802.11g traffic yocompia Linux - Wireless Networking 0 11-22-2003 10:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:54 AM.

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