Friday, April 19, 2013

Disable networking/internet from command line on a Mac

If you want to quickly disable internet/networking to test offline features. Doing it frequently with System preferences GUI is quite a slow workflow.

Here is the command to disable your ethernet quickly.
sudo ifconfig en0 down
to activate it again
sudo ifconfig en0 up

If you are connected via wireless you can disable it with
networksetup -setairportpower en1 off
to activate it again, use
networksetup -setairportpower en1 on

en0 and en1 are device name, which you can get from running the following command
networksetup -listallhardwareports

1 comment:

  1. If you are connecting via the network and bring down the network, or wireless as stated, you won’t also be able to bring it back up via the network as suggested. Like sawing off a tree limb you are sitting on. Invoking a script to bring down and the bring back up the interface should do the trick.