nftnl-rs

Crates.ionftnl-rs
lib.rsnftnl-rs
version0.5.1
created_at2024-03-18 00:01:57.86097+00
updated_at2025-09-28 22:44:11.677635+00
descriptionA Rust crate for Linux Netlink Nftables client for direct control on the netfilter via netlink socket.
homepage
repositoryhttps://codeberg.org/4neko/nftnl-rs
max_upload_size
id1176903
size177,974
Aleksandr Morozov (eesekaj)

documentation

README

nftnl-rs (A Nftables manipulation library)

This is a crate (currently in development) which implements a netlink protocol to communicate with the Linux Nftables firewall.

This crate is not activly developed because there was a requirment to control the content of the set of the table.

Due to the complexity of the protocol, there are no plans to activly maintain or develop this crate.

This crate is in its early development state. It is not planned to extend its functionality! Use at your own risk.

This crate was developed only for the tables/sets manipulations i.e add/del/get!!!

At the moment this crate allows to:

  • perform operations on the sets i.e add IP, remove IP, get IP from the list.
Policy
  • This crate i.e code is NOT an Open Source software. This is a FREE (gratis) software and follows the principle of Sources Available/Disclosed software which should be fairly used.
  • It is published under FSF/OSI approved licenses however author does not follow/share/respect OSI and FSF principles and phylosophy.
  • License is subject to be changed in further versions without warning.
  • If you are using code in non-free (in terms of gratis) software you MUST NEVER demand a development of any features which are missing and needed for your business if you are not sponsoring/contributing those changes.
  • Access to the code can be limited by author to specific entities due to the local laws (not my bad or fault)(despite what is said in the license).
AI policy
  • AI generated sloppy code is prohibited. AI generates slop "a priori" (anyway).
  • Licenses (thank you OSS sectarians ) do not anyhow limit AI training, but f^ck you all - ChatGPT, CockPilot, especially Claude and rest unidentified cr@p.
  • It is strongly discouraged from using the AI based tools to write or enhance the code. AI slope would 100% violate the license by introducing the 3rd party licensed code.
Pull requests

The pull requests are now supported because the repository was moved to Codeberg. The alternative way is to send patches over the email to patch[at]4neko.org.

In case if you would like to contribute the code, please use pull request. Your pull request should include:

  • Description of changes and why it is needed.

  • Test the pull request.

    In case of you prefer email and patch files please consider the following:

  • For each feature or fix, please send patches separatly.

  • Please write what your patch is implementing or fixing.

  • I can read the code and I am able to understand it, so don't write a poem or essay in the description to the patches.

  • Please test your patch.

Questions about license MPL-2.0
  • Can I use the MPL-2.0 licensed code (crate) in larger project licensed with more permissive license like BSD or MIT.

Yes, MPL- and Apache-licensed code can be used with an MIT codebase (so in that sense, they are "compatible"). However, the MPL- / Apache-licensed code remains under its original license. (So although compatible, you cannot relicense someone else's MPL or Apache code into the MIT license.) This means that your final codebase will contain a mix of MPL, Apache, and MIT licensed code. As an example, MPL has weak copyleft, so if you modified an MPL file, that file (including your changes) must remain under the MPL license.

Answer1

-I want to distribute (outside my organization) executable programs or libraries that I have compiled from someone else's unchanged MPL-licensed source code, either standalone or part of a larger work. What do I have to do?

You must inform the recipients where they can get the source for the MPLed code in the executable program or library you are distributing (i.e., you must comply with Section 3.2). You may distribute any executables you create under a license of your choosing, as long as that license does not interfere with the recipients' rights to the source under the terms of the MPL.

MPL2.0 FAQ

Version

v 0.5.1-development, Rust edition 2024

License:

Sources are available under: MPL-2.0

Issues tracker:

The project has moved to Codeberg.

Examples

For examples, see /examples/ directory.

Get IP from the table's set. i.e performing the following command:

$ sudo nft list set ip table-test table-set
use std::{net::IpAddr, str::FromStr};

use nftnl_rs::Nfprot

fn main()
{

    let hosts = [IpAddr::from_str("127.0.1.3").unwrap(), IpAddr::from_str("127.0.1.4").unwrap()];

    let res = nftnl_rs::add_hosts_to_table(hosts.as_slice(), "table-test", "table-set");
}

Commit count: 0

cargo fmt