| Crates.io | ipfw-rs |
| lib.rs | ipfw-rs |
| version | 0.1.1 |
| created_at | 2024-03-26 23:37:16.56321+00 |
| updated_at | 2025-09-29 13:19:53.535314+00 |
| description | A Rust crate which allows to send commands to the FreeBSD IPFW firewall. |
| homepage | |
| repository | https://codeberg.org/4neko/ipfw-rs |
| max_upload_size | |
| id | 1187383 |
| size | 109,199 |
#ipfw-rs
A crate which provides userspace interface to FreeBSD IPFW Firewall which allows to control IPFW directly without executing ipfw(8) every time when it is required to block network host or to check the list.
This crate supports only actual and recent FreeBSD version which is 14.0, but it seems that protocol did not changed much, so may work on FreeBSD 13!
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.
v 0.1.1development, Rust edition 2024
Sources are available under: BSD-2-Clause
Add, Remove, Test commands on tables (a list of hosts: IP/IPv6/DNS at the moment)
Flush table
extern crate ipfw_rs;
use ipfw_rs::{Ipfw, IpfwCmd};
fn main()
{
let ipfw = Ipfw::new().unwrap();
let res =
ipfw.ipfw_table_handler("testtable", IpfwCmd::Add { hosts: vec!["127.0.1.1", "127.0.2.0/24"], req_atomic_op: true }, false);
match res
{
Ok(r) => println!("res: '{}'", r),
Err(e) => println!("err: '{}'", e)
}
let res =
ipfw.ipfw_table_handler("testtable", IpfwCmd::Test { hosts: vec!["127.0.1.1", "127.0.2.0/24"]}, false);
match res
{
Ok(r) => println!("res: '{}'", r),
Err(e) => println!("err: '{}'", e)
}
let res =
ipfw.ipfw_table_handler("testtable", IpfwCmd::Flush, false); //{ hosts: vec!["127.0.1.2"] }, false);// { hosts: vec!["127.0.1.1", "127.0.2.0/24"], req_atomic_op: true }, false);
match res
{
Ok(r) => println!("res: '{}'", r),
Err(e) => println!("err: '{}'", e)
}
println!("Hello, world!");
}