Running your own servers? Hate managing firewall rules?
Ript is a clean and opinionated Domain Specific Language for describing firewall rules, and a tool with database migrations-like functionality for applying these rules with zero downtime.
At Ript’s core is an easy to use Ruby DSL for describing both simple and complex sets of iptables firewall rules. After defining the hosts and networks you care about:
…you use Ript’s helpers for accepting, dropping, & rejecting packets, as well as for performing DNAT and SNAT:
The DSL provides many helpful shortcuts for DRYing up your firewall rules, and tries to do as much of the heavy lifting for you as possible.
Part of Ript being opinionated is that it doesn’t expose all the underlying features of iptables. This was done for several reasons:
- The DSL would become complex, and thus harder to use.
- Not all features within iptables map to Ript’s DSL
- Ript caters for the simple-to-moderately complex use cases that 80% of users have. If you need to use iptables features documented deep within the man pages, Ript is almost certainly not the tool for you.
While the DSL is pretty, we didn’t write Ript because of it - we wrote it because we’re working with tens of thousands of iptables rules & making several changes a day to those rules, and the traditional way of applying changes doesn’t cut it at scale.
Most tools try to apply firewall rules by flushing all the loaded rules and loading in new ones. This works fine if you only have a few hundred rules, but as soon as you start scaling into thousands of rules, the load time becomes very noticable.
The effects of this are fairly simple: the rule load time manifests itself as downtime.
Because the ruleset has to be applied serially, rules at the end of the set are held up by rules still being applied at the beginning of the set. From a service provider’s perspective, this means that a rule change for one customer can end up causing downtime for other completely unrelated customers. Not cool.
iptables-restore help with this, but you still end up writing + applying rules by hand - a tedious task if you’re making lots of firewall changes every day.
Ript’s killer feature is incrementally applying rules.
Ript generates firewall chains in a very specific way that allows it to apply new rules incrementally, and clean out old rules intelligently. Here’s an example session:
I’ll also be giving a talk about Ript at linux.conf.au in Canberra in January 2013.