Crate iptables [] [src]

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

extern crate iptables;

fn main() {
    let ipt = iptables::new(false).unwrap();
    assert_eq!(ipt.new_chain("nat", "NEWCHAINNAME").unwrap(), true);
    assert_eq!(ipt.append("nat", "NEWCHAINNAME", "-j ACCEPT").unwrap(), true);
    assert_eq!(ipt.exists("nat", "NEWCHAINNAME", "-j ACCEPT").unwrap(), true);
    assert_eq!(ipt.delete("nat", "NEWCHAINNAME", "-j ACCEPT").unwrap(), true);
    assert_eq!(ipt.delete_chain("nat", "NEWCHAINNAME").unwrap(), true);
}

Modules

error

Structs

IPTables

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

new

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