Rand Stats

Linux::NFTables

zef:FRITH

Actions Status

NAME

Linux::NFTables - An interface to libnftables, a library to interact with Linux NFTables

SYNOPSIS

use Linux::NFTables;

my Linux::NFTables $nft .= new;
$nft.exec('list ruleset');

DESCRIPTION

Linux::NFTables is an interface to libnftables, a library to interact with Linux NFTables

Return values

Many methods return a Bool value to indicate whether the action has been successfully performed.

new()

The constructor takes no arguments.

multi method dry-run(Bool $active!)

multi method dry-run(--> Bool)

The first method sets the operations for a dry run, the second returns the state of the dry-run flag.

List commands produce output, but no real action will be performed on the firewall rules.

flags(UInt $flags!)

flags(--> UInt)

The first method allows to add bit-mapped flags to modify the library's behavior, the second returns the value of the flags.

The available flags are:

debug(UInt $flags!)

debug(--> UInt)

The first method sets, the second reads the debug level.

The available levels are:

set-output(Str $filename! --> Bool)

set-output(--> Bool)

These methods redirect the command output to a file or to stdout.

set-error(Str $filename! --> Bool)

set-error(--> Bool)

These methods redirect the command errors to a file or to stderr.

buffer-output(Bool $active --> Bool)

buffer-output(--> Bool)

buffer-error(Bool $active --> Bool)

buffer-error(--> Bool)

These methods ask to send the command outout or error to a buffer. They take one Bool parameter; when invoked without parameter they default to False.

get-output-buffer(--> Str)

get-error-buffer(--> Str)

These methods return the output or error buffer content (if the the system was asked to buffer its output)

add-path(Str $path! --> Bool)

clear-path(--> Bool)

The first method adds a search path for the include command in nftables, the second one removes all the include paths.

add-var(Str $var! --> Bool)

clear-vars()

The first method defines a variable, the second removes all variables.

exec(Str $command! --> Bool)

This method executes a nftables command.

exec-from-file(Str $filename! --> Bool)

This method reads and executes nftables comands from a file.

C Library Documentation

For more details on libnftables see man 3 libnftables. For more details on nftables see https://wiki.nftables.org/wiki-nftables/index.php/Main_Page.

Prerequisites

This module requires the libnftables library to be installed. On Debian-like systems install both libnftables1 and libnftables-dev.

Installation

To install it using zef (a module management tool):

$ zef install Linux::NFTables

AUTHOR

Fernando Santagata nando.santagata@gmail.com

COPYRIGHT AND LICENSE

Copyright 2023 Fernando Santagata

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.