If you use your Mac as an intermediate machine to provide Internet access or other network services, you could have the need to enable the IP forwarding. I looked through the web to check how could I enable or disable this ability, which is disabled by default.
I developed a small and smart AppleScript to allow the user to activate or deactivate this system option very quickly. I compiled the script, and now I offer it as an (open source) app to launch when needed; you can find it here.
[robg adds: Here's the source code, just in case the above site ever goes away.
(*
(c) Copyright 2010 Joris Berthelot <admin at eexit dot net> httpt://www.eexit.net
*)
display dialog "Current state of IP Forwarding:" & return & return & (do shell script "sysctl net.inet.ip.forwarding") & return & (do shell script "sysctl net.inet.ip.fastforwarding") with title "IP Forward — eexit.net" with icon note buttons {"Enable", "Disable", "Quit"} cancel button 3 default button 1
set choice to button returned of result
try
if choice contains "Enable" then
display dialog (do shell script "sysctl -w net.inet.ip.forwarding=1 net.inet.ip.fastforwarding=1" with administrator privileges) with title "IP Forward — eexit.net" with icon note buttons {"Done"} default button 1 giving up after 10
end if
if choice contains "Disable" then
display dialog (do shell script "sysctl -w net.inet.ip.forwarding=0 net.inet.ip.fastforwarding=0" with administrator privileges) with title "IP Forward — eexit.net" with icon note buttons {"Done"} default button 1 giving up after 10
end if
on error the error_message number the error_number
beep
display dialog "Error: " & the error_number & return & the error_message with title "IP Forward — eexit.net" with icon stop buttons {"Quit"} default button 1
end tryMac OS X Hints
http://hints.macworld.com/article.php?story=201004131638545