Posted on 12-22-2008 01:49 PM
I didn't see this one in the resource kit, and it took me some tinkering to
get it just right. I hope some of you get some use out of this script (I'm
attaching a zipped file just in case your mail reader, or any mail servers
between you and I, mangle the text below).
This script can be part of a configuration (make sure it's run "at reboot"),
a policy for already-deployed systems, or run ad-hoc out of Casper Remote.
#!/bin/bash
##### HEADER BEGINS #####
# scr_sys_turnOffIPv6.bash
#
# Created 20081222 by Miles A. Leacy IV
# miles.leacy at themacadmin.com
# Modified 20081222 by Miles A. Leacy IV
# Copyright 2008 Miles A. Leacy IV
#
# This script may be copied and distributed freely as long as this header
remains intact.
#
# This script is provided "as is". The author offers no warranty or
guarantee of any kind.
# Use of this script is at your own risk. The author takes no
responsibility for loss of use,
# loss of data, loss of job, loss of socks, the onset of armageddon, or any
other negative effects.
#
# Test thoroughly in a lab environment before use on production systems.
# When you think it's ok, test again. When you're certain it's ok, test
twice more.
#
# This script turns off IPv6 on all network interfaces present.
# Run as an "at reboot" script when imaging with Casper.
#
##### HEADER ENDS #####
# first, change $IFS environment variable to allow a "for" statement to
capture an entire line.
SAVEIFS=$IFS
IFS=$(echo -en "
")
# get list of network services on system
for i in $( networksetup -listallnetworkservices ) do
# skip descriptive line in networksetup output
descriptive=echo $i|awk {'print $1'}
if [ "$descriptive" != "An" ];then
# if there is no asterix before the service name, turn IPv6 off via
networksetup
has_asterix=echo $i|grep ^*
if [ $? -ne 0 ];then
networksetup -setv6off $i; echo "IPv6 disabled on" $i
else
# if there is an asterix before the service name, strip the asterix, then
run networksetup
# using the asterix-free service name
disabled_service=echo $has_asterix|awk -F* {'print $2'}
networksetup -setv6off $disabled_service; echo "IPv6 disabled on"
$disabled_service
fi
fi
done
echo "IPv6 has been turned off for all network services."
# restore $IFS
IFS=$SAVEIFS
exit 0
----------
Miles A. Leacy IV
? Certified System Administrator 10.4
? Certified Technical Coordinator 10.5
? Certified Trainer
Certified Casper Administrator
----------
voice: 1-347-277-7321
miles.leacy at themacadmin.com
www.themacadmin.com
Posted on 12-22-2008 01:54 PM
I will! Thanks Miles! Just had a request from the network guys to turn it off just last week.
Craig E
Posted on 12-22-2008 02:05 PM
No problem. One more note... I've only tested this script on Leopard. I
believe it should work on Tiger as well.
----------
Miles A. Leacy IV
? Certified System Administrator 10.4
? Certified Technical Coordinator 10.5
? Certified Trainer
Certified Casper Administrator
----------
voice: 1-347-277-7321
miles.leacy at themacadmin.com
www.themacadmin.com
Posted on 09-29-2016 01:12 PM
For an update, this is easier done in Terminal
networksetup -setv6off Ethernet
networksetup -setv6off Wi-Fi
Posted on 01-31-2024 11:05 AM
would be good to have an update...