Just as for the ipchains command, you can (Multiple domain web hosting)

Just as for the ipchains command, you can use the -x argument to show the output in expanded format with unit figures. Resetting the Counters The IP accounting counters will overflow if you leave them long enough. If they overflow, you will have difficulty determining the value they actually represent. To avoid this problem, you should read the accounting data periodically, record it, and then reset the counters back to zero to begin collecting accounting information for the next accounting interval. The ipfwadm and ipchains commands provide you with a means of doing this quite simply: # ipfwadm -A -z or: # ipchains -Z or: # iptables -Z You can even combine the list and zeroing actions together to ensure that no accounting data is lost in between: # ipfwadm -A -l -z or: # ipchains -L -Z or: # iptables -L -Z -v These commands will first list the accounting data and then immediately zero the counters and begin counting again. If you are interested in collecting and using this information regularly, you would probably want to put this command into a script that recorded the output and stored it somewhere, and execute the script periodically using the cron command. Flushing the Ruleset One last command that might be useful allows you to flush all the IP accounting rules you have configured. This is most useful when you want to radically alter your ruleset without rebooting the machine. The -f argument in combination with the ipfwadm command will flush all of the rules of the type you specify. ipchains supports the -F argument, which does the same: # ipfwadm -A -f or: # ipchains -F or: # iptables -F This flushes all of your configured IP accounting rules, removing them all and saving you having to remove each of them individually. Note that flushing the rules with ipchains does not cause any user-defined chains to be removed, only the rules within them. Passive Collection of Accounting Data One last trick you might like to consider: if your Linux machine is connected to an Ethernet, you can apply accounting rules to all of the data from the segment, not only that which it is transmitted by or destined for it. Your machine will passively listen to all of the data on the segment and count it. You should first turn IP forwarding off on your Linux machine so that it doesn’t try to route the datagrams it receives.65 n the 2.0.36 and 2.2 kernels, this is a matter of: # echo 0 >/proc/sys/net/ipv4/ip_forward This isn’t a good thing to do if your Linux machine serves as a router. If you disable IP forwarding, it will cease to route! Do this only on a machine with a single physical network interface.

Leave a Reply