Solved

Shell script to change state of Firewall Application when on a specific IP Address

Posted on 2009-05-06
3
400 Views
Last Modified: 2013-12-26
Basically I need a shell script to change Firewall State when on a specific IP address. If its on this 192.169 IP address turn firewall app off, but it needs to read the state of the firewall first.

Someone helped me with part of this but I just found out I need something else add.
here is what I have but it is not working. I'm getting error.

Thanks you so much
#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"
 
else
#Enable firewall to Set access for specific services and applications
If ['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

Open in new window

0
Comment
Question by:Samhenry
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 40

Accepted Solution

by:
omarfarid earned 500 total points
ID: 24319205
0
 

Author Comment

by:Samhenry
ID: 24321018
yes you can disregard this i messed up. thank you so much for answering my questions
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 24321876
welcome :)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question