LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 01-07-2004, 04:25 PM   #1
sqn
Member
 
Registered: Apr 2002
Distribution: Ubuntu, Arch, freeBSD, Slackware
Posts: 210

Rep: Reputation: 30
trafic acounting with iptables


I'm trying to count my trafic with iptables. Here i put the script use to count my trafic:
------- start script -------
iptables -N ACCT

iptables -I FORWARD -j ACCT
iptables -A ACCT -s 192.168.0.1/32 -d 0.0.0.0/0 -o eth0
iptables -A ACCT -s 0.0.0.0/0 -d 192.168.0.1/32 -i eth0

------- end script ----------

I use an cable modem link, with an fixed IP adress, my out interface is eth0 and inside interface is eth1.
I'm trying to count the trafic my inside machine are making. Can you help me, because my script doesn't seam to work

THX in advance
 
Old 01-07-2004, 06:11 PM   #2
g-rod
Member
 
Registered: Dec 2003
Location: Long Island, NY USA
Distribution: RedHat, SUSE
Posts: 336

Rep: Reputation: 30
I am not quit sure what you want to do but you can find how many packets/bytes have gone though a rule with
iptables -L -n -v;
Hope that helps.
 
Old 01-08-2004, 05:32 AM   #3
leckie
Member
 
Registered: Dec 2003
Location: Australia
Distribution: Mandrake 9.2
Posts: 151

Rep: Reputation: 30
u really need a helper program to do this. i use ipacsum
download from freshmeat have fun more then enough info in readme files.
 
Old 01-08-2004, 08:26 AM   #4
Noerr
Member
 
Registered: May 2002
Location: Dalec, HU
Distribution: Redhat 7.3
Posts: 696

Rep: Reputation: 30
whatever rule you setup with iptables it will count all data going through
let say you wanna know howmuch www you are using do this

iptables -I FORWARD -p tcp -s 192.168.1.0/24 --dport 80
or how much data comes in through http
iptables -I FORWARD -p tcp -d 192.168.1.0/24 --sport 80

then do
iptables -L FORWARD -v
and you will get all counters

You want to zero counters do
iptables -Z FORWARD

please note that you don't even need to do any jump (-j SOMEWHARE) -- don't do -j ACCEPT, because it may mess up your firewall. Also make sure to include your counter before forwarding rules, otherwise won't count
 
Old 01-08-2004, 03:34 PM   #5
sqn
Member
 
Registered: Apr 2002
Distribution: Ubuntu, Arch, freeBSD, Slackware
Posts: 210

Original Poster
Rep: Reputation: 30
Thx for your help it's working now
Noerr: Thx man this is the stuff i was looking for thax again.
leckie: Your help will be tested thx to you to man
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
acounting and billing software ali_dd15 Linux - Software 0 11-02-2005 05:41 AM
Trafic shaper ... how ? sys7em Linux - Networking 0 01-24-2005 06:35 PM
My provider does not allow me to route the trafic??? sys7em Linux - Networking 1 11-03-2004 05:43 PM
trafic limits gekkie_007 Linux - Networking 1 02-23-2003 05:06 AM
Monitor http trafic Justinw Linux - Networking 2 05-04-2001 07:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:30 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