Features 🌟
-
🛡️ Safe and Easy-to-Use Abstraction: Provides a high-level, safe abstraction over the nftables JSON API, making it easier and safer to work with nftables in Rust.
-
🛠️ Comprehensive Functions: Includes a wide range of functions to create, read, and apply nftables rulesets directly from Rust, streamlining the management of firewall rules.
-
📄 JSON Parsing and Generation: Offers detailed parsing and generation capabilities for nftables rulesets in JSON format, enabling seamless integration and manipulation of rulesets.
-
💡 Inspired by nftnl-rs: While taking inspiration from nftnl-rs,
nftables-rsfocuses on utilizing the JSON API for broader accessibility and catering to diverse use cases.
Motivation
nftables-rs is a Rust library designed to provide a safe and easy-to-use abstraction over the nftables JSON API, known as libnftables-json.
This library is engineered for developers who need to interact with nftables, the Linux kernel's next-generation firewalling tool, directly from Rust applications. By abstracting the underlying JSON API, nftables-rs facilitates the creation, manipulation, and application of firewall rulesets without requiring deep knowledge of nftables' internal workings.
Installation
[]
= "0.3.0"
Linux nftables v0.9.3 or newer is required at runtime: nft --version
Example
Here are some examples that show use cases of this library.
Check out the tests/ directory for more usage examples.
Apply ruleset to nftables
This example applies a ruleset that creates and deletes a table to nftables.
use ;
/// Applies a ruleset to nftables.
Parse/Generate nftables ruleset in JSON format
This example compares nftables' native JSON out to the JSON payload generated by this library.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Maintainers
This project is currently maintained by the following developers:
| Name | Email Address | GitHub Username |
|---|---|---|
| Jasper Wiegratz | wiegratz@uni-bremen.de | @jwhb |