Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Enable IP forwarding using an AppleScript Internet
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 try
I have not tested this one.]
    •    
  • Currently 2.25 / 5
  You rated: 3 / 5 (8 votes cast)
 
[9,428 views]  

Enable IP forwarding using an AppleScript | 1 comments | Create New Account
Click here to return to the 'Enable IP forwarding using an AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Version with line-wrapping
Authored by: Krioni on Apr 16, '10 06:32:50AM
Broke this down so the lines don't stretch out so long.

(*
(c) Copyright 2010 Joris Berthelot <admin at eexit dot net> httpt://www.eexit.net
*)
property ffEnableCode : "sysctl -w net.inet.ip.forwarding=1 net.inet.ip.fastforwarding=1"
property ffDisableCode : "sysctl -w net.inet.ip.forwarding=0 net.inet.ip.fastforwarding=0"

set currentState to "Current state of IP Forwarding:" & return & return & 
	(do shell script "sysctl net.inet.ip.forwarding") & return & 
	(do shell script "sysctl net.inet.ip.fastforwarding")

display dialog currentState 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
		set ffEnableResult to (do shell script ffEnableCode with administrator privileges)
		display dialog ffEnableResult 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
		set ffDisableResult to (do shell script ffDisableCode with administrator privileges)
		display dialog ffDisableResult 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 try
---
http://www.danshockley.com


[ Reply to This | # ]