|
OpenBSD Security Functionally paranoid! |
|
Thread Tools | Display Modes |
|
|||
Triggering pf.conf anchor load based on ip detected
I have an anchor for a service that is needed ONLY when the device is present. otherwise, those ports should be closed and that anchor ignored.
I can write a script that will load and unload the anchor from the cli obviosuly, but there must be a better way to check wether the anchor should be loaded. I could write a script to run as a cron every 2 minutes / constant running loop to check if that ip is in use like: Code:
#!/bin/bash ping -c 1 $IP >> /dev/null if [ $? -eq 0 ]; then echo "set return state 0" echo "run pfctl -a load anchor ports open on subset rules until connection down" pfctl -a $anchor -sr fi Code:
ping -c 1 $IP >> /dev/null if [ $? -eq 1 ]; then echo "set return state 1" echo "connection down, unload anchor" pfctl -a $anchor -F all fi Code:
#!/bin/bash result=1 while [ $result -neq 0 ]; do ping -c 1 $IP result=$? done Has anyone ever seen something like what i am looking to accomplish? Code:
if machine detected ( pfctl load anchor ) else ( ignore ruleset anchor) if state changes and ip offline unload currently loaded anchor Would be nice if I didn't have to have cron jobs running every 2 minutes and then executing a script. Hoping there is a pf.conf setting to do this or something more elegant that my if ping works load anchor if ping fails unload anchor. Thanks! Last edited by daemonbak; 13th July 2015 at 08:34 PM. Reason: added script |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
5.4 amd64 on Thinkpad x200: "render error detected" on booting. | karl | OpenBSD Installation and Upgrading | 2 | 5th November 2013 04:28 AM |
Partition(s) present but not detected after panic | jb_daefo | FreeBSD General | 0 | 29th May 2009 07:01 PM |
Memory Not Detected | jrs | OpenBSD Installation and Upgrading | 3 | 19th May 2009 05:50 PM |
difference between rc.conf and loader.conf | disappearedng | FreeBSD General | 5 | 3rd September 2008 05:54 AM |
Load averages on Linux | corey_james | Other BSD and UNIX/UNIX-like | 2 | 22nd July 2008 03:39 AM |