#nftables #netfilter #firewall #iptables #api-bindings #nft

nftnl

Safe abstraction for libnftnl. Provides low-level userspace access to the in-kernel nf_tables subsystem

9 releases (5 breaking)

0.6.2 Feb 11, 2022
0.6.1 Feb 4, 2021
0.6.0 Nov 23, 2020
0.5.0 Jun 4, 2020
0.1.0 Sep 19, 2018

#286 in Unix APIs

Download history 2404/week @ 2023-12-15 1417/week @ 2023-12-22 1965/week @ 2023-12-29 2372/week @ 2024-01-05 2454/week @ 2024-01-12 2046/week @ 2024-01-19 2148/week @ 2024-01-26 3048/week @ 2024-02-02 3639/week @ 2024-02-09 2193/week @ 2024-02-16 2710/week @ 2024-02-23 3817/week @ 2024-03-01 4755/week @ 2024-03-08 5028/week @ 2024-03-15 6865/week @ 2024-03-22 2712/week @ 2024-03-29

20,353 downloads per month

MIT/Apache

360KB
8K SLoC

nftnl

Safe abstraction for libnftnl. Provides low-level userspace access to the in-kernel nf_tables subsystem. See nftnl-sys for the low level FFI bindings to the C library.

Can be used to create and remove tables, chains, sets and rules from the nftables firewall, the successor to iptables.

This library currently has quite rough edges and does not make adding and removing netfilter entries super easy and elegant. That is partly because the library needs more work, but also partly because nftables is super low level and extremely customizable, making it hard, and probably wrong, to try and create a too simple/limited wrapper. See examples for inspiration. One can also look at how the original project this crate was developed to support uses it: Mullvad VPN app

Understanding how to use libnftnl and implementing this crate has mostly been done by reading the source code for the nftables program and attaching debuggers to the nft binary. Since the implementation is mostly based on trial and error, there might of course be a number of places where the underlying library is used in an invalid or not intended way. Large portions of libnftnl are also not covered yet. Contributions are welcome!

Selecting version of libnftnl

See the documentation for the corresponding sys crate for details: nftnl-sys This crate has the same features as the sys crate, and selecting version works the same.

License: MIT/Apache-2.0

Dependencies

~2MB
~41K SLoC