Question : Shell Script to turn off the Application Firewall when user is on IP address 128.183, then turn it back on when they are not at that address

I am looking to simply shut off the Application level firewall when the active IP address begins with 128.183.

The goal is when the user is on 128.183, they have no firewall for the time being. When a network changes and they are no longer 128.183, turn the firewall back on.
 I was looking for a shell script do do something like this, to keep checking their IP Address

Answer : Shell Script to turn off the Application Firewall when user is on IP address 128.183, then turn it back on when they are not at that address

I am not familiar with the commands but I think the script structure should look like:

#Get IP Address
ifconfig -a | grep 192.169
if [ $? -eq 0 ]
then
       #disable firewall
       if [`defaults read "/Library/Preferences/com.apple.sharing.firewall" state` -eg 1]
       then
              defaults write /Library/Preferences/com.apple.alf globalstate -int 0
              killall -HUP socketfilterfw
              echo "Firewall Off"
       #Enable firewall to Set access for specific services and applications
       elif [`defaults read "/Library/Preferences/com.apple.sharing.firewall" state` -eg 0]
       then
              defaults write /Library/Preferences/com.apple.alf globalstate -int 1
              killall -HUP socketfilterfw
              echo "Firewall On"
        fi
fi
Random Solutions  
 
programming4us programming4us