Skip to main content

Hello.


Does anybody have a  script that disables ipv6 over ethernet connections that works.


Thanks 


D

@DaveB1 This script will do it for all active interfaces:


#!/bin/bash

# Sets any network interface to IPv6 Link-Local Only mode

SAVEIFS=$IFS
IFS=$'\\n'
interfaceList=($(networksetup -listallnetworkservices | grep -v -i -E "\\*"))
interfaceCount=${#interfaceList[@]}
IFS=$SAVEIFS

for (( i = 0; i < interfaceCount; i++ ));
do
echo "Working on interface ${interfaceList[$i]}"
/usr/sbin/networksetup -setv6linklocal "${interfaceList[$i]}"
/bin/sleep 1
done

exit 0

@DaveB1 This script will do it for all active interfaces:


#!/bin/bash

# Sets any network interface to IPv6 Link-Local Only mode

SAVEIFS=$IFS
IFS=$'\\n'
interfaceList=($(networksetup -listallnetworkservices | grep -v -i -E "\\*"))
interfaceCount=${#interfaceList[@]}
IFS=$SAVEIFS

for (( i = 0; i < interfaceCount; i++ ));
do
echo "Working on interface ${interfaceList[$i]}"
/usr/sbin/networksetup -setv6linklocal "${interfaceList[$i]}"
/bin/sleep 1
done

exit 0

Does this work on all interfaces or all active interfaces? I have also been poking at this myself for some time as a backlog thing and keep getting stuck on needing the network interface to be active and each dongle having its own interface. 


Does this work on all interfaces or all active interfaces? I have also been poking at this myself for some time as a backlog thing and keep getting stuck on needing the network interface to be active and each dongle having its own interface. 


That will do all active interfaces (the filter for anything with an * excludes inactive interfaces)


Thanks for your thoughts.

When I run the script in terminal directly on the mac. I get the below output and when I check the network settings ipv6 is still set to Automatically. I know I can change manually but I have 100+ macs to change this setting for so trying to avoid the personal touch. 



 





Last login: Wed May  7 16:15:31 on ttys000


DaveB1 ~ %


DaveB1 ~ % SAVEIFS=$IFS


IFS=$'\\n'


interfaceList=($(networksetup -listallnetworkservices | grep -v -i -E "\\*"))


interfaceCount=${#interfaceList[@]}


IFS=$SAVEIFS


 


for (( i = 0; i < interfaceCount; i++ ));


do


    echo "Working on interface ${interfaceListf$i]}"


    /usr/sbin/networksetup -setv6linklocal "${interfaceList"$i]}"


    /bin/sleep 1


done


 


exit 0


zsh: command not found:     echo


zsh: no such file or directory:     /usr/sbin/networksetup


zsh: no such file or directory:     /bin/sleep


zsh: command not found:     echo


zsh: no such file or directory:     /usr/sbin/networksetup


zsh: no such file or directory:     /bin/sleep


zsh: command not found:     echo


zsh: no such file or directory:     /usr/sbin/networksetup


zsh: no such file or directory:     /bin/sleep


 


Saving session...


...copying shared history...


...saving history...truncating history files...


...completed.


 


sProcess completed]


 


 


Thanks for your thoughts.

When I run the script in terminal directly on the mac. I get the below output and when I check the network settings ipv6 is still set to Automatically. I know I can change manually but I have 100+ macs to change this setting for so trying to avoid the personal touch. 



 





Last login: Wed May  7 16:15:31 on ttys000


DaveB1 ~ %


DaveB1 ~ % SAVEIFS=$IFS


IFS=$'\\n'


interfaceList=($(networksetup -listallnetworkservices | grep -v -i -E "\\*"))


interfaceCount=${#interfaceList[@]}


IFS=$SAVEIFS


 


for (( i = 0; i < interfaceCount; i++ ));


do


    echo "Working on interface ${interfaceListf$i]}"


    /usr/sbin/networksetup -setv6linklocal "${interfaceList"$i]}"


    /bin/sleep 1


done


 


exit 0


zsh: command not found:     echo


zsh: no such file or directory:     /usr/sbin/networksetup


zsh: no such file or directory:     /bin/sleep


zsh: command not found:     echo


zsh: no such file or directory:     /usr/sbin/networksetup


zsh: no such file or directory:     /bin/sleep


zsh: command not found:     echo


zsh: no such file or directory:     /usr/sbin/networksetup


zsh: no such file or directory:     /bin/sleep


 


Saving session...


...copying shared history...


...saving history...truncating history files...


...completed.


 


sProcess completed]


 


 


You can't simply paste the script into Terminal. Save it as a file named SetIPv6Mode.sh (use an editor like BBEdit) then in Terminal type the command "sudo " (include the space after sudo) then enter the path to the saved script file (dragging the the file from a. Finder window into the Terminal window sill do that for you) and hit return. When prompted for your password enter it (it won't echo the characters) and hit return.


Or just add the script to Jamf Pro and run it as a Script payload in Policy.


You can't simply paste the script into Terminal. Save it as a file named SetIPv6Mode.sh (use an editor like BBEdit) then in Terminal type the command "sudo " (include the space after sudo) then enter the path to the saved script file (dragging the the file from a. Finder window into the Terminal window sill do that for you) and hit return. When prompted for your password enter it (it won't echo the characters) and hit return.


Or just add the script to Jamf Pro and run it as a Script payload in Policy.


You rock.
Thank you for your help.


 


Reply