Blocking internet access for a specific application on Mac OS X
How can I block internet access to a specific application in Mac OS X? I need this to be done from the command line and hopefully use the ipfw terminal command.
Specifically I am looking to toggle the internet connection on and off in the iPhone simulator application since there is no airplane mode.
You can use the Lulu open-source macOS firewall that aims to block unknown outgoing connections, unless explicitly approved by the user. Whilst it has a GUI, the set of blocked applications can be controlled via the command line by modifying the config file /Library/Objective-See/LuLu/rules.plist
as explained in the Lulu webpage (near the bottom).
I don't have a command line solution to do so, but there is an application that can successfully do exactly what you want.
Little Snitch is an application that has the ability to block certain processes and monitor connections. You could use this to block the iPhone simulator process from any network connectivity which would achieve the same effects as airplane mode, minus the native airplane mode features such as "You must turn on Airplane mode to use this feature", but so will a terminal command.
Hope this helps a little and good luck with developing your app! :)
You could also block incoming connections to an application by using the firewall. follow the instructions given below:
https://support.apple.com/en-us/HT201642