All Projects → picatz → iptablez

picatz / iptablez

Licence: MIT license
🦑 A friendly Ruby API to iptables.

Programming Languages

ruby
36898 projects - #4 most used programming language

🦑 Iptablez

A friendly Ruby API to iptables. With a squid for a mascot.

🚧 Development Notice

Iptablez is still under development.

Installation

Currently, a pre-release gem is avaiable to install with the --pre flag to help with early testing.

$ gem install iptablez --pre

Usage

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.

🐚 iptablez-shell

This is a TODO. Iptablez provides an interactive shell via the iptablez-shell command.

$ iptablez-shell
🦑  ~ (main)> Iptablez.version

🦑 iptablez-cli

This is a TODO. Iptablez provides a simple command-line application via the iptablez-cli command.

$ iptablez-cli -h

iptablez-web

This is a TODO. Iptablez provides a web application that can be started via the iptablez-web command.

iptablez-api

This is a TODO. A simple REST API that can be started via the iptablez-api command.

License

The gem is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].