Skip to content

Instantly share code, notes, and snippets.

@tempusthales
Last active December 23, 2020 00:19
Show Gist options
  • Save tempusthales/d78dc8202685b5d9463c446c92e675c4 to your computer and use it in GitHub Desktop.
Save tempusthales/d78dc8202685b5d9463c446c92e675c4 to your computer and use it in GitHub Desktop.
#!/bin/sh
# ipv6-off.sh
# Disable IPv6 on all interfaces.
IFS=$'\n'
net=`networksetup -listallnetworkservices | grep -v asterisk`
for i in $net
do
networksetup -setv6off "$i"
echo "$i" IPv6 is Off
done
exit 0
@tempusthales
Copy link
Author

Updated the script, and cleaned it off a bit

@greggles
Copy link

Thanks for sharing this!

I was curious what the asterisk grep is doing so I ran the first part of the command and:

greggles@gregs-mbp ~/p/> networksetup -listallnetworkservices
An asterisk (*) denotes that a network service is disabled.
...

It seems like you could make the script more reliable and more readable by using something like:

net=`networksetup -listallnetworkservices | grep -v "denotes that a network service is disabled"`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment