Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 01-07-2004, 05:25 PM   #1
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 -d -o eth0
iptables -A ACCT -s -d -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, 07:11 PM   #2
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, 06:32 AM   #3
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, 09:26 AM   #4
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 --dport 80
or how much data comes in through http
iptables -I FORWARD -p tcp -d --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, 04:34 PM   #5
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


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
acounting and billing software ali_dd15 Linux - Software 0 11-02-2005 06:41 AM
Trafic shaper ... how ? sys7em Linux - Networking 0 01-24-2005 07:35 PM
My provider does not allow me to route the trafic??? sys7em Linux - Networking 1 11-03-2004 06:43 PM
trafic limits gekkie_007 Linux - Networking 1 02-23-2003 06:06 AM
Monitor http trafic Justinw Linux - Networking 2 05-04-2001 08:05 AM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:00 AM.

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