python-netfilter is a set of modules for the  Python programming language which allows you to manipulate  netfilter rules.

It is released under the terms of the GNU General Public License version 3 or later.

Simple example

  from netfilter.rule import Rule,Match
  from netfilter.table import Table

  rule = Rule(
    in_interface='eth0',
    protocol='tcp',
    matches=[Match('tcp', '--dport 80')],
    jump='ACCEPT')))

  table = Table('filter')
  table.append_rule('INPUT', rule)

  table.delete_rule('INPUT', rule)

Getting python-netfilter

The following releases of python-netfilter are available for download:

Alternatively, you can checkout the latest development version using  Subversion as follows:

svn co https://svn.bolloretelecom.eu/opensource/python-netfilter/trunk/ python-netfilter