my lame attempt at a shell script...

Eric F Crist ecrist at secure-computing.net
Mon Jan 3 14:49:18 PST 2005


On Jan 3, 2005, at 4:40 PM, Paul Schmehl wrote:

> --On Monday, January 03, 2005 04:21:41 PM -0600 Eric F Crist 
> <ecrist at secure-computing.net> wrote:
>
>> I believe this is my last question.  I need to do some math.  Anyone
>> familiar with ipfw knows that you can add a rule with:
>>
>> ipfw add [num] my firewall rule
>>
>> What I'm trying to do is have that number auto-computed.  So, my 
>> command
>> *should* look something like:
>>
>> $ipfwcmd add [rulenum1 + 50] my firewall rule $other $variables
>>
>> Make sense?  I just want to add a new rule, let it figure out the rule
>> number.  That way, I can leave a space of 48 rules (for minor, 
>> on-the-fly
>> tweaking, etc.
>>
>
> First answer a question.  Are you wanting to write these rules on the 
> fly? Or have them available for the next restart of the firewall?  Or 
> both?
>
> You have a problem, because you want to use one, generic script to set 
> up multiple, varied firewalls.  In order for the script to work, 
> you'll have to be able to calculate what number to use next based on 
> what number was *last used* on *that* server.
>
> There's several ways to solve that problem.  You could write a 
> placemarker to a file.  (Silly, but easy.)  You could use rulesets, 
> and just write a new line to a ruleset and let ipfw figure it out.  
> (Much better I think.) If you also want to add the rule on the fly, 
> you can just reload that ruleset.  That way you use a fixed name and 
> number (e.g. on-the-fly_rules, set 2) and just add rules to the 
> ruleset, unload and reload the ruleset (ipfw set 2 disable; write the 
> new rule to the ruleset; ipfw set 2 enable)

Paul,

By on-the-fly, I meant by manually typing in a new rule on the command 
line.  From there, I'd take the output of ipfw show and figure out 
where I want that rule placed.  So, for the purposes of this script, I 
just want it to add new rules at an interval of 50.  Within the script, 
different sets of rules will be grouped by the 10000, but I'll worry 
about that vailidation on my own.  The syntax is where my limitations 
lie.

Thanks.
_______________________________________________________
Eric F Crist                  "I am so smart, S.M.R.T!"
Secure Computing Networks              -Homer J Simpson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20050103/d14bf464/PGP.bin


More information about the freebsd-questions mailing list