Skip to main content

I’m tightening a few things down and was searching across JAMF Nation for a resolve in 10.10.2, specifically with finding a script on enabling the firewall. I ran across this script which seemed to bit quite a bit older and created by a couple of techs, obviously this was written while functioning under an older OS:



!/bin/bash



Written by Nate Walck and Clint Armstrong



Liberty University 2009



This Script will automatically enable or disable the firewall depending upon which network it is on.



This function turns the firewall on or off, depending upon which state is desired.



If the firwall is already in the state desired, the script will leave it in that state.



function firewall {
#Reads the current state of the firewall and stores it in variable fw
fw=$(defaults read /Library/Preferences/com.apple.alf globalstate)



#This compares the option passed to function firewall to its current state.
if f "$1" != "$fw" ]
then
#If the option pased is different from current state, it changes it to the passed value.
defaults write /Library/Preferences/com.apple.alf globalstate -int $1
#For troubleshooting purposes, you can put in 'say $1' to see which state is being set.
fi
}



Determines if resolv.conf exists.



if test -e /var/run/resolv.conf
then
#This stores the domain line of resolv.conf into variable NETWORK.
NETWORK=$(cat /var/run/resolv.conf | grep domain | awk '{print $2}')



#This case looks at $NETWORK for specific domains and runs commands accordingly
case "$NETWORK" in



#If on VPN, function firewall turns the firewall on.
vpn.yourcompany.com
firewall 1
;;



#On any other company domain, function firewall turns firewall off.
*.yourcompany.com)
firewall 0
;;



#On any other domain, function firewall turns firewall on.
*)
firewall 1
;;



esac



else
#If no network connection exists, function firewall turns the firewall on.
firewall 1



fi





This seems to be a better fix: https://jamfnation.jamfsoftware.com/discussion.html?id=13874



Anyone have a better resolve under 10.10.2?

@msample : Not sure what you'e asking? The post (mine) linked to works fine. I've been using it on a policy since @nessts found and posted that.


Got it working with:



defaults write /Library/Preferences/com.apple.alf global state -int -1