Giter VIP home page Giter VIP logo

rpfload's Introduction

rpfload

rpfload is a Perl script for applying pf firewall configurations with automatic rollback to a backup pf.conf file after a configurable period of time.

If you have ever made a mistake in pf.conf and locked yourself out or caused other calamity, this can be helpful.

Rationale

You can accomplish something similar with a simple shell one-liner like this:

# pfctl -f /etc/pf.conf && sleep 60 && pfctl -d

This will load /etc/pf.conf, wait 60 seconds, then disable the firewall.

But if you don't want to totally disable PF, rpfload allows you to switch between config files a little easier than doing so in a oneliner, can be sent to the background with & and the process killed later if needed, and logs the actions it takes to the syslog, so you can check /var/log/messages and see exactly which config file it ended up running, or whether it disabled PF completely.

Installing

To install rpfload and its man page, run:

# make install

Usage

See the man page (rpfload.1) for full usage examples. Below is a brief explanation to get you running.

To reproduce the oneliner above, use the -d flag to disable PF on timeout:

# rpfload -d -f /etc/pf.conf

This will run pfctl -f /etc/pf.conf, wait 60 seconds (the default timeout length), then run pfctl -d if the process has not been killed before then.

You can also replace the config file with a backup on timeout. This will require a backup configuration file that will be applied after the timeout is reached. A simple usage example might look like this:

# rpfload -f /etc/pf.conf -b /etc/pf.conf.backup

This will run pfctl -f /etc/pf.conf, wait 60 seconds, then run pfctl -f /etc/pf.conf.backup. If you Ctrl-C or kill the process' PID before the 60 seconds have passed, the current configuration will be kept and it will not revert to the backup.

rpfload will helpfully print its own PID, so you can run it in the background and kill the process later if you are happy with the config and don't want to revert.

You can also tell rpfload to overwrite the live config with the backup config file when reverting with the -o flag:

# rpfload -o -f /etc/pf.conf -b /etc/pf.conf.backup

This will load /etc/pf.conf, wait 60 seconds, then load /etc/pf.conf.backup and copy /etc/pf.conf.backup to /etc/pf.conf, replacing it.. This is useful if you end up rebooting or run sh /etc/netstart and want to ensure your backup pf.conf is loaded instead of a broken one.

Logs

rpfload will log what it is doing to the syslog. Check /var/log/messages

Bugs

Probably.

rpfload's People

Contributors

jsf0 avatar sbennett1990 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.