NFTables module — pyroute2 0.5.15 documentation

# NFTables module

class `pyroute2.nftables.main.` `NFTables`(version=1, attr_revision=0, nfgen_family=2)
  `table`(cmd, **kwarg)

    Example:

        nft.table('add', name='test0')

  `chain`(cmd, **kwarg)

    Example:

        #
        # default policy 'drop' for input
        #
        nft.chain('add',
                  table='test0',
                  name='test_chain0',
                  hook='input',
                  type='filter',
                  policy=0)

  `rule`(cmd, **kwarg)

    Example:

        from pyroute2.nftables.expressions import ipv4addr, verdict
        #
        # allow all traffic from 192.168.0.0/24
        #
        nft.rule('add',
                 table='test0',
                 chain='test_chain0',
                 expressions=(ipv4addr(src='192.168.0.0/24'),
                              verdict(code=1)))