28

I'm struggling with some iptables rules. I'm a newbie in iptables. I found some resources where I get the following command related to iptables. This is stored in a file that will be executed.

[0:0] -A PREROUTING -s 10.1.0.0/24 -p tcp -m tcp --dport 81 -j DNAT --to-destination 10.1.0.6:3128

Can anybody explain me what does [0:0] mean? Also, some link related to this in iptables are welcome.

Thanks in advance!

P.S. If you need more rules, just let me know.

2 Answers 2

31

The [0:0] or [1280:144299] or whatever are the count of [Packets:Bytes] that have been trough the chain . They are saved when you run an iptables-save command and are used by the iptables-restore command to initialise the counters.


The Packets and bytes values can be useful for some statistical purposes. Issuing an iptables-save command with the -c argument would then make it possible for us to reboot without breaking our statistical and accounting routines. (Quoted from Iptables Tutorial 1.2.2 - by Oskar Andreasson) Conclusively, restoring the iptables rules with Packets and bytes specified will not affect the rule behavior, just will keep a "stateful" track of Packets respectively bytes that match the rule.

1
  • What if I save my rules with those specified. Does it influence the networking? If yes, how.
    – artaxerxe
    Mar 28, 2012 at 5:48
8

Every rule has two counters; the number of packets and the number of bytes that have matched each rule. The default policies also have counters.

This syntax goes in the input to iptables-restore and sets the counters to whatever number is in the square brackets. iptables-save puts the current value of the counters into the square brackets in its output.

You can see human-readable counts for each rule using:

iptables -L -n -v

and the raw values with

iptables -L -n -v -x

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .