enable/disable internet connection from terminal/with terminal commands?

Joined
Feb 3, 2008
Messages
315
Reaction score
5
Points
18
Can anyone tell me how to enable/disable my internet connections (ethernet/wi-fi) with terminal commands?
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
16,033
Reaction score
2,438
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
The commands you use will vary slightly between Ethernet and WiFi.

The command
Code:
sudo ifconfig en0 down

Will take down the interface regardless of it being Ethernet or WiFi. You would bring it back up by replacing the down with up.

If you are using WiFi, you can use another command to turn off the power to the WiFi as well with the command
Code:
networksetup -setairportpower en0 off

To enable the power, you would replace off with on.

Read more:
https://alvinalexander.com/mac-os-x/mac-airport-networking-terminal-command-line-off-on
http://osxdaily.com/2011/05/31/enable-disable-airport-wireless-connections-command-line/
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top