Project

iptablez

0.0
No commit activity in last 3 years
No release in over 3 years
A friendly Ruby API to iptables.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.14
~> 10.0
~> 3.0

Runtime

>= 0
 Project Readme

🦑 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.