Crate iptables

source ·
Expand description

Provides bindings for iptables application in Linux. 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.

Example

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());

Modules

Structs

  • Contains the iptables command and shows if it supports -w and -C options. Use new method to create a new instance of this struct.

Functions

  • Creates a new IPTables Result with the command of ‘iptables’ if is_ipv6 is false, otherwise the command is ‘ip6tables’.