14 releases

0.5.2 Jun 6, 2024
0.5.1 Sep 18, 2023
0.5.0 Feb 1, 2022
0.4.3 Mar 7, 2021
0.1.2 Feb 11, 2017

#286 in Network programming

Download history 1583/week @ 2024-09-02 1599/week @ 2024-09-09 1118/week @ 2024-09-16 1556/week @ 2024-09-23 1969/week @ 2024-09-30 2326/week @ 2024-10-07 1961/week @ 2024-10-14 1879/week @ 2024-10-21 2077/week @ 2024-10-28 1939/week @ 2024-11-04 1719/week @ 2024-11-11 1610/week @ 2024-11-18 1771/week @ 2024-11-25 1575/week @ 2024-12-02 1649/week @ 2024-12-09 1501/week @ 2024-12-16

6,594 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