I plan to use iptables
to measure my Internet traffic (inspired by Peter Krumins' great article http://www.catonmat.net/blog/traffic-accounting-with-iptables).
The computer which is intended to measure traffic currently forwards all LAN traffic to and from the Internet.
I tried to figure out in which chains all transferred bytes (upload+download) are counted. The filter
FORWARD
chain is the only chain with more than a Megabyte after opening several websites (it shows 17M
). It seems to be the download (+ upload maybe).
But the following observation made me suspicious:
me@computer:~$ sudo iptables -vL -t raw
Chain PREROUTING (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
me@computer:~$ sudo iptables -vL -t raw
Chain PREROUTING (policy ACCEPT 34 packets, 2244 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 16 packets, 2664 bytes)
pkts bytes target prot opt in out source destination
Even though I visited some websites, the raw
PREROUTING
chain still had 0 bytes when running sudo iptables -vL -t raw
the first time (the first run of sudo iptables -vL -t raw
stood out by its long execution time of more than a second). A few seconds later, both raw
chains had more than 2000 bytes.
To me, it seems to be starting to count after the first query and missing all earlier bytes.
I expected the raw
PREROUTING
chain to count all bytes of forwarded LAN traffic, because the following flow chart suggests that: http://stuffphilwrites.com/2014/09/iptables-processing-flowchart