How can I check the hit count for each rule in iptables?

前端 未结 3 2068
南旧
南旧 2021-02-07 00:03

I want to know how can I find out which rule was accessed and how many times, from the access list I have created using iptables.

My firewall has over 1000 input and ou

相关标签:
3条回答
  • 2021-02-07 00:15

    I use the following to check on my iptables rules:

    iptables -nvL [INPUT|FORWARD|OUTPUT|myCHAINNAME] --line-numbers | less
    

    The -n speeds up the process by not doing hostname lookups

    The line numbers help with deleting rules:

    iptables -D [INPUT|FORWARD|OUTPUT|myCHAINNAME] [Rule#]
    

    HTH

    0 讨论(0)
  • 2021-02-07 00:19

    iptables will list packet and byte counters if you specify option -v for verbose, e.g. iptables -vL. Likewise iptables-save will list all entries including the mentioned counters for each chain, but not for each table entry (on some systems iptables-save requires option -c to include counters).

    0 讨论(0)
  • 2021-02-07 00:24

    You can also use collectds iptables module to aggregate the counters:

    https://collectd.org/wiki/index.php/Iptables

    0 讨论(0)
提交回复
热议问题