DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD Security

OpenBSD Security Functionally paranoid!

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   (View Single Post)  
Old 13th July 2015
daemonbak daemonbak is offline
Fdisk Soldier
 
Join Date: Feb 2015
Posts: 51
Default 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
But that would be a sloppy workaround. Would using something like ifstated to look for that machine and then load that rule?

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
And of course, obviously if machine exits network/loses connection/powered off unload that anchor effectively closing the ports and returning the firewall to stealth mode on change of machine state not present.

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
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT. The time now is 09:47 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick