13 releases

0.5.1 Sep 18, 2023
0.5.0 Feb 1, 2022
0.4.3 Mar 7, 2021
0.4.1 Dec 28, 2020
0.1.2 Feb 11, 2017

#600 in Network programming

Download history 1336/week @ 2023-12-20 1523/week @ 2023-12-27 1939/week @ 2024-01-03 1757/week @ 2024-01-10 1952/week @ 2024-01-17 2320/week @ 2024-01-24 2066/week @ 2024-01-31 1521/week @ 2024-02-07 1596/week @ 2024-02-14 1445/week @ 2024-02-21 1797/week @ 2024-02-28 1267/week @ 2024-03-06 1479/week @ 2024-03-13 1719/week @ 2024-03-20 2235/week @ 2024-03-27 1406/week @ 2024-04-03

7,027 downloads per month
Used in netavark

MIT license

20KB
442 lines

Rust iptables

crates.io Documentation Build License

This crate provides bindings for iptables application in Linux (inspired by go-iptables). This crate uses iptables binary to manipulate chains and tables. This source code is licensed under MIT license that can be found in the LICENSE file.

[dependencies]
iptables = "*"

Getting started

1- Import the crate iptables and manipulate chains:

let ipt = iptables::new(false).unwrap();

assert!(ipt.new_chain("nat", "NEWCHAINNAME").is_ok());
assert!(ipt.append("nat", "NEWCHAINNAME", "-j ACCEPT").is_ok());
assert!(ipt.exists("nat", "NEWCHAINNAME", "-j ACCEPT").unwrap());
assert!(ipt.delete("nat", "NEWCHAINNAME", "-j ACCEPT").is_ok());
assert!(ipt.delete_chain("nat", "NEWCHAINNAME").is_ok());

For more information, please check the test file in tests folder.

Dependencies

~5MB
~89K SLoC