Opening port in Firewall with Script instead of ServerAdmin?

Hi,

I tried to google this but didn't find good leads. What is the way to open ports in the OS X Server 10.5 Software Firewall by using a shellscript instead of the GUI ServerAdmin tool?

thanks a lot
simon

MacBook Air Rev.A, Mac OS X (10.5.7)

Posted on Aug 8, 2009 3:58 AM

Reply
1 reply

Aug 26, 2009 7:48 AM in response to zaxxon72

At the most basic level:
------
#!/bin/bash

HOST_IP = "123.123.123.123"

/sbin/ipfw -f add 30000 allow tcp from $HOST_IP to any dst-port 20-21
------

This would add a single rule, assigned to rule number 30000. It opens ports 20 and 21 for the specified IP. After installing this rule via script there are various things that will cause your firewall to be flushed and the rule will be lost. For example, just poking around in ServerAdmin can cause an unintentional flush and reloading of the firewall rules - you'll need a way to run your script again when it happens.

Check the man page and google for info on ipfw.

David

Message was edited by: DavidWil

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Opening port in Firewall with Script instead of ServerAdmin?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.