Monday, April 4, 2011

OS X Adaptive Firewall Automated Blacklisting

OS X Mini Server comes with an incarnation of 'ipfw' as its built in kernel firewall. Configuration of ipfw in an IPv4-only world is pretty simple. The Server Admin GUI covers the basics. The details are in /etc/ipfilter.

Along with the 'ipfw' firewall comes something called 'Adaptive Firewall'.  OS X's "Network Services Administration" indicates that this adaptive firewall 'just works':
Adaptive Firewall

Mac OS X v10.6 uses an adaptive firewall that dynamically generates a firewall rule if a user has 10 consecutive failed login attempts. The generated rule blocks the user’s computer for 15 minutes, preventing the user from attempting to log in.

The adaptive firewall helps to prevent your computer from being attacked by unauthorized users. The adaptive firewall does not require configuration and is active when you turn on your firewall.
Apparently my Mac Air is doing something to annoy the Adaptive Firewall on my mini. After a day of running ipfw, my Air looses the ability to connect to the Mini Server and 'ipfw show' shows a deny any for the IP address of my Mac Air. I have no clue why it's blacklisting me - I'm connecting via AFP, Samba and Time Machine, all of which work fine until they don't.

Fortunately I keep a handful of Windows 7 laptops around. They don't get blacklisted even when I try.

To tweak the adaptive firewall start with:


Then:

sudo cat /etc/af.plist

sudo cat /var/db/af/blacklist

And when you get tired of being blacklisted by your own server:

/usr/libexec/afctl -w 192.168.0.0/24

The adaptive firewall may (or may not) log to:

/var/log/alf.log

depending on various sysctl, socketfilterfw and serveradmin settings. As far as I can tell, mine doesn't log anything. Interesting things like 'I've blacklisted you" apparently are worthy only of /dev/null.

I bought the Mini Server for my home network because after a decade of running Solaris, I've decided that I want simple, straight forward technology at home so I can spend less time reading man pages and tweaking config files.

2 comments:

  1. ever get a fix for this? i've just had it start happening in my school, and i'm not impressed. teachers are getting a little miffed

    ReplyDelete
  2. Flow:

    afctl -w

    will white list a network. You should be able to white list your local networks.

    --Mike

    ReplyDelete