Support for nftables
Append a rule to the specified table & chain.
starting with the chain. Trying to force users to adapt to a new method of creating rules would be irritating at best, and we already have a parser that can handle it.
CLI Example:
salt '*' nftables.append filter input \
rule='tcp dport 22 log accept'
IPv6:
salt '*' nftables.append filter input \
rule='tcp dport 22 log accept' \
family=ipv6
Build a well-formatted nftables rule based on kwargs. A table and chain are not required, unless full is True.
If full is True, then table, chain and command are required. command may be specified as either insert, append, or delete. This will return the nftables command, exactly as it would be used from the command line.
If a position is required (as with insert or delete), it may be specified as position. This will only be useful if full is True.
If connstate is passed in, it will automatically be changed to state.
CLI Examples:
salt '*' nftables.build_rule match=state \
connstate=RELATED,ESTABLISHED jump=ACCEPT
salt '*' nftables.build_rule filter input command=insert position=3 \
full=True match=state state=related,established jump=accept
IPv6:
salt '*' nftables.build_rule match=state \
connstate=related,established jump=accept \
family=ipv6
salt '*' nftables.build_rule filter input command=insert position=3 \
full=True match=state state=related,established jump=accept \
family=ipv6
Check for the existence of a rule in the table and chain
starting with the chain. Trying to force users to adapt to a new method of creating rules would be irritating at best, and we already have a parser that can handle it.
CLI Example:
salt '*' nftables.check filter input \
rule='tcp dport 22 log accept'
IPv6:
salt '*' nftables.check filter input \
rule='tcp dport 22 log accept' \
family=ipv6
New in version 2014.7.0.
Check for the existence of a chain in the table
CLI Example:
salt '*' nftables.check_chain filter input
IPv6:
salt '*' nftables.check_chain filter input family=ipv6
Check for the existence of a table
CLI Example:
salt '*' nftables.check_table nat
in its entirety, or the rule's position in the chain.
starting with the chain. Trying to force users to adapt to a new method of creating rules would be irritating at best, and we already have a parser that can handle it.
CLI Examples:
salt '*' nftables.delete filter input position=3
salt '*' nftables.delete filter input \
rule='tcp dport 22 log accept'
IPv6:
salt '*' nftables.delete filter input position=3 family=ipv6
salt '*' nftables.delete filter input \
rule='tcp dport 22 log accept' \
family=ipv6
New in version 2014.7.0.
Delete the chain from the specified table.
CLI Example:
salt '*' nftables.delete_chain filter input
salt '*' nftables.delete_chain filter foo
IPv6:
salt '*' nftables.delete_chain filter input family=ipv6
salt '*' nftables.delete_chain filter foo family=ipv6
New in version 2014.7.0.
Create new custom table.
CLI Example:
salt '*' nftables.delete_table filter
IPv6:
salt '*' nftables.delete_table filter family=ipv6
Flush the chain in the specified table, flush all chains in the specified table if chain is not specified.
CLI Example:
salt '*' nftables.flush filter
salt '*' nftables.flush filter input
IPv6:
salt '*' nftables.flush filter input family=ipv6
New in version 3002.
Return the current policy for the specified table/chain
Name of the table containing the chain to check
Name of the chain to get the policy for
Networking family, either ipv4 or ipv6
CLI Example:
salt '*' nftables.get_policy filter input
IPv6:
salt '*' nftables.get_policy filter input family=ipv6
Get the handle for a particular rule
starting with the chain. Trying to force users to adapt to a new method of creating rules would be irritating at best, and we already have a parser that can handle it.
CLI Example:
salt '*' nftables.get_rule_handle filter input \
rule='tcp dport 22 log accept'
IPv6:
salt '*' nftables.get_rule_handle filter input \
rule='tcp dport 22 log accept' \
family=ipv6
Return a data structure of the current, in-memory rules
CLI Example:
salt '*' nftables.get_rules
salt '*' nftables.get_rules family=ipv6
New in version 3002.
Return a list of dictionaries comprising the current, in-memory rules
Networking family, either ipv4 or ipv6
CLI Example:
salt '*' nftables.get_rules_json
salt '*' nftables.get_rules_json family=ipv6
Return a data structure of the rules in the conf file
CLI Example:
salt '*' nftables.get_saved_rules
Insert a rule into the specified table & chain, at the specified position.
If position is not specified, rule will be inserted in first position.
starting with the chain. Trying to force users to adapt to a new method of creating rules would be irritating at best, and we already have a parser that can handle it.
CLI Examples:
salt '*' nftables.insert filter input \
rule='tcp dport 22 log accept'
salt '*' nftables.insert filter input position=3 \
rule='tcp dport 22 log accept'
IPv6:
salt '*' nftables.insert filter input \
rule='tcp dport 22 log accept' \
family=ipv6
salt '*' nftables.insert filter input position=3 \
rule='tcp dport 22 log accept' \
family=ipv6
Return a data structure of the current, in-memory tables
CLI Example:
salt '*' nftables.list_tables
salt '*' nftables.list_tables family=ipv6
New in version 2014.7.0.
Create new chain to the specified table.
CLI Example:
salt '*' nftables.new_chain filter input
salt '*' nftables.new_chain filter input \
table_type=filter hook=input priority=0
salt '*' nftables.new_chain filter foo
IPv6:
salt '*' nftables.new_chain filter input family=ipv6
salt '*' nftables.new_chain filter input \
table_type=filter hook=input priority=0 family=ipv6
salt '*' nftables.new_chain filter foo family=ipv6
New in version 2014.7.0.
Create new custom table.
CLI Example:
salt '*' nftables.new_table filter
IPv6:
salt '*' nftables.new_table filter family=ipv6
Changed in version 3002.
Save the current in-memory rules to disk. On systems where /etc/nftables is a directory, a file named salt-all-in-one.nft will be dropped inside by default. The main nftables configuration will need to include this file.
CLI Example:
salt '*' nftables.save /etc/nftables
New in version 3002.
Set the current policy for the specified table/chain. This only works on chains with an existing base chain.
Name of the table containing the chain to modify
Name of the chain to set the policy for
accept or drop
Networking family, either ipv4 or ipv6
CLI Example:
salt '*' nftables.set_policy filter input accept
IPv6:
salt '*' nftables.set_policy filter input accept family=ipv6
Return version from nftables --version
CLI Example:
salt '*' nftables.version