Solved

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

Posted on 2009-05-06
3
392 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
  • 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

757 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now