https://github.com/yaa110/rust-iptables
Rust bindings for iptables
https://github.com/yaa110/rust-iptables
bindings iptables netfilter rust rust-crate
Last synced: 6 days ago
JSON representation
Rust bindings for iptables
- Host: GitHub
- URL: https://github.com/yaa110/rust-iptables
- Owner: yaa110
- License: mit
- Created: 2017-02-11T11:10:52.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2025-02-20T18:32:10.000Z (about 2 months ago)
- Last Synced: 2025-04-01T14:16:44.677Z (13 days ago)
- Topics: bindings, iptables, netfilter, rust, rust-crate
- Language: Rust
- Homepage: https://crates.io/crates/iptables
- Size: 18.6 KB
- Stars: 88
- Watchers: 5
- Forks: 26
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-rust-cn - yaa110/rust-iptables - ci.org/yaa110/rust-iptables.svg?branch=master">](https://travis-ci.org/yaa110/rust-iptables) (Libraries / Platform specific)
- awesome-rust - yaa110/rust-iptables - ci.org/yaa110/rust-iptables.svg?branch=master">](https://travis-ci.org/yaa110/rust-iptables) (Libraries / Platform specific)
- awesome-rust - yaa110/rust-iptables
- awesome-rust-cn - yaa110/rust-iptables
- awesome-rust-zh - yaa110/rust-iptables - [iptables](https://www.netfilter.org/projects/iptables/index.html)绑定 [<img src="https://api.travis-ci.org/yaa110/rust-iptables.svg?branch=master">](https://travis-ci.org/yaa110/rust-iptables) (库 / 平台特定)
README
Rust iptables
=============[](https://crates.io/crates/iptables) [](https://docs.rs/iptables) [](https://github.com/yaa110/rust-iptables/actions/workflows/build.yml) [](https://github.com/yaa110/rust-iptables/blob/master/LICENSE)
This crate provides bindings for [iptables](https://www.netfilter.org/projects/iptables/index.html) application in Linux (inspired by [go-iptables](https://github.com/coreos/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.
```toml
[dependencies]
iptables = "*"
```## Getting started
1- Import the crate `iptables` and manipulate chains:```rust
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.