Help language development. Donate to The Perl Foundation
Linux::NFTables - An interface to libnftables, a library to interact with Linux NFTables
use Linux::NFTables; my Linux::NFTables $nft .= new; $nft.exec('list ruleset');
Linux::NFTables is an interface to libnftables, a library to interact with Linux NFTables
Many methods return a Bool value to indicate whether the action has been successfully performed.
The constructor takes no arguments.
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.
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:
NFT_CTX_OUTPUT_NONE
NFT_CTX_OUTPUT_REVERSEDNS
NFT_CTX_OUTPUT_SERVICE
NFT_CTX_OUTPUT_STATELESS
NFT_CTX_OUTPUT_HANDLE
NFT_CTX_OUTPUT_JSON
NFT_CTX_OUTPUT_ECHO
NFT_CTX_OUTPUT_GUID
NFT_CTX_OUTPUT_NUMERIC_PROTO
NFT_CTX_OUTPUT_NUMERIC_PRIO
NFT_CTX_OUTPUT_NUMERIC_SYMBOL
NFT_CTX_OUTPUT_NUMERIC_TIME
NFT_CTX_OUTPUT_NUMERIC_ALL
NFT_CTX_OUTPUT_TERSE
The first method sets, the second reads the debug level.
The available levels are:
NFT_DEBUG_NONE
NFT_DEBUG_SCANNER
NFT_DEBUG_PARSER
NFT_DEBUG_EVALUATION
NFT_DEBUG_NETLINK
NFT_DEBUG_MNL
NFT_DEBUG_PROTO_CTX
NFT_DEBUG_SEGTREE
These methods redirect the command output to a file or to stdout.
These methods redirect the command errors to a file or to stderr.
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.
These methods return the output or error buffer content (if the the system was asked to buffer its output)
The first method adds a search path for the include command in nftables, the second one removes all the include paths.
The first method defines a variable, the second removes all variables.
This method executes a nftables command.
This method reads and executes nftables comands from a file.
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.
This module requires the libnftables library to be installed. On Debian-like systems install both libnftables1 and libnftables-dev.
To install it using zef (a module management tool):
$ zef install Linux::NFTables
Fernando Santagata [email protected]
Copyright 2023 Fernando Santagata
This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.