|
|
Add firewall rules via the Terminal
to add firewall rules via the terminal i use this command:
oops...typos
to add a rule via cli the exact command is
configure ipfw
ipfw is located in /sbin. If you want to configure ipfw using the terminal, you can do the following:
- stop the built-in firewall in system prefs. if you have it running. - create the folder /Library/StartupItems/ipfw - copy ipfw into that folder using this command in the terminal:
- using the terminal, we'll create "StartupParameters.plist" in the folder /Library/StartupItems/ipfw so type the following:
- now paste in the following:
- save it and exit pico- from the terminal, you will add your firewall rules to the file /etc/ipfw.conf To open pico in the terminal, and create the ipfw.conf file, type this:
- Now add your firewall rules. Here is a very basic example:
- when you're finished adding all your rules, save the file and exit pico.- if you want firewall logging to be routed into the ipfw.log, you'll need to edit the /etc/syslog.conf, because by default, ipfw logging will show up in the system.log - to enable logging to the ipfw.log, type this in the terminal:
- then add this to replace the existing ipfw.log info:
- since ipfw is already running you'll need to stop it, and start it again to activate your rules.- to disable, and then enable ipfw, type this in the terminal:
- to verify your current firewall rules, type this from terminal:
- this should show the rules that you just entered into /etc/ipfw.conf- to see the parameters that apply to ipfw, type this in terminal:
- it should show enable=1, and if you want verbose logging (if it doesn't show verbose=1) type this in terminal:
- you can also set a limit on the number of log entries (provided that you added "log" to any of your ipfw rules) by setting verbose_limit to the maximum number of log entries that you choose, for example:
- this is good if you know that you're going to have people pounding on your firewall, so you don't have a ton of log entries, otherwise you don't really need to set it.And that's basically all there is to it. Users who are new to the terminal, or who aren't familiar with firewall rules, and what they do, should read up on it, or ask someone for help. The man page for ipfw is a place to start. If you're sharing things from your machine, you'll want to create rules to allow these functions. If you find that something doesn't work anymore after enabling ipfw, that's the first place you should start looking.
Add firewall rules via the Terminal
I thought that the purpose of the "0" was to make the rule being added the top rule, however all the rules I try to add with the 0 are tacked onto the END of my ruleset whether I use the 0 or not. What the heck? Am I missing something? I'm running 10.3.9.
For example:
>sudo ipfw 0 add deny ip from 1.1.1.1 to anyWhy does it get stuck as rule 12290 (the last rule barring 65535)? Rob |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.08 seconds |
|