Mac OS X: 实用脚本程序(bash scripts)系列-12

本文提供了一个用于在MacOSX 10.4至10.6上启用防火墙的shell脚本。该脚本通过检测操作系统版本来调整防火墙设置,并支持隐身模式及UDP流量控制。

这个是从其它网站复制的,打开Mac OS X 10.4, 10.5, 10.6内置的防火墙。

#!/bin/sh # enable_firewall.sh # # Patrick Gallagher # http://macadmincorner.com # Stealth Mode - Set to 0 to disable # Stealth mode prevents machine from responding to ping requestst # Be aware that this would prevent tools such as ARD from discovering # the machine, though bonjour on the same subnet will still work osversionlong=`sw_vers -productVersion` osvers=${osversionlong:3:1} # Check if this is being run by root if [ "$(whoami)" != "root" ] ; then echo "Must be root to run this command." >&2 exit 1 fi # Enable firewall for Tiger if [ $osvers -eq 4 ]; then echo "Setting firewall on a ${osversionlong} machine" /usr/bin/defaults write /Library/Preferences/com.apple.sharing.firewall state -bool YES # UDP, change to 0 to disable /usr/bin/defaults write /Library/Preferences/com.apple.sharing.firewall udpenabled -int 1 # Stealth, change to 0 to disable /usr/bin/defaults write /Library/Preferences/com.apple.sharing.firewall stealthenabled -int 1 /usr/libexec/FirewallTool fi # Enable firewall for Leopard or Snow Leopard if [ $osvers -ge 5 ]; then echo "Setting firewall on a ${osversionlong} machine" # Globalstate - Set to 0 for off, 1 for on, 2 for "Block all incoming access" /usr/bin/defaults write /Library/Preferences/com.apple.alf globalstate -int 1 /usr/bin/defaults write /Library/Preferences/com.apple.alf stealthenabled -int 1 fi

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值