A friendly Ruby API to iptables
. With a squid for a mascot.
Iptablez is still under development.
Currently, a pre-release
gem is avaiable to install with the --pre
flag to help with early testing.
$ gem install iptablez --pre
Easily list all of the iptables
chains.
Iptablez.chains
# => ["INPUT", "FORWARD", "OUTPUT", "cats", "dogs"]
Iptablez::Chains.all
# => ["INPUT", "FORWARD", "OUTPUT", "cats", "dogs"]
Maybe you just want the default chains?
Iptablez::Chains.defaults
# => ["INPUT", "FORWARD", "OUTPUT"]
Iptablez::Chains::DEFAULT
# => ["INPUT", "FORWARD", "OUTPUT"]
Create a new user defined chain(s)?
Iptablez::Chains.create(name: "dogs")
# => true
Iptablez::Chains.create(names: ["dogs", "cats"])
# => {"dogs"=>false, "cats"=>true}
Delete a user defined chain(s) ( that's empty )?
Iptablez::Chains.delete(name: "dogs")
# => true
Iptablez::Chains.delete(names: ["dogs", "cats"])
# => {"dogs"=>false, "cats"=>true}
Maybe rename a user defined chain?
Iptablez::Chains.rename(from: "dogs", to: "puppies")
# => true
Iptablez::Chains.rename(pairs: { "dogs" => "puppies", "cats" => "kittens"} )
# => {"dogs"=>{"puppies"=>false}, "cats"=>{"kittens"=>true}}
Why not check the default chain policies?
Iptablez::Chains.policies
# => {"INPUT"=>"ACCEPT", "FORWARD"=>"ACCEPT", "OUTPUT"=>"ACCEPT"}
Want to be a little bit more specific when checking policies? I got'chu.
Iptablez::Chains.policy?(name: "INPUT", policy: "ACCEPT")
# => true
Iptablez::Chains.policy?(name: "FORWARD", policy: "ACCEPT")
# => false
Iptablez::Chains.policies(names: ["FORWARD", "OUTPUT"])
# => {"FORWARD"=>"ACCEPT", "OUTPUT"=>"ACCEPT"}
Feel like flushing some chains? Maybe you're about to delete them and need them to not be empty. I feel you.
Iptablez::Chains.flush(name: "wizards")
# => true
Iptablez::Chains.flush(names: ["wizards", "hobbits"])
# => {"wizards"=>false, "hobbits"=>true}
Curious if there are any user defined chains?
Iptablez::Chains.user_defined?
# => true
Curious if a specific chain(s) has been user defined?
Iptablez::Chains.user_defined?(name: "frogs")
# => false
Iptablez::Chains.user_defined?(names: ["wizards", "hobbits"])
# => {"wizards"=>true, "hobbits"=>true}
TODO add more stuff.
This is a TODO. Iptablez provides an interactive shell via the iptablez-shell
command.
$ iptablez-shell
π¦ ~ (main)> Iptablez.version
This is a TODO. Iptablez provides a simple command-line application via the iptablez-cli
command.
$ iptablez-cli -h
This is a TODO. Iptablez provides a web application that can be started via the iptablez-web
command.
This is a TODO. A simple REST API that can be started via the iptablez-api
command.
The gem is available as open source under the terms of the MIT License.